Clojure

Support hinting arg vectors

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: Release 1.3
  • Fix Version/s: Release 1.3
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Currently, return type hints must be on function or var names, e.g.:

(defn ^String foo [])

This is in contrast to primitive return type declarations, which must be on function arg vectors:

(defn foo ^long [])

The latter is preferred because:

  • Different arities of the same function can be typed differently
  • All of the type information for a given function hangs off of a single value (the arg vector)

For these reasons, supporting type hints on arg vectors as well is desirable. This would remove the (confusing and purely historic at this point) syntactic difference between type hints and signature declarations (with the current function/var name hinting support to be potentially deprecated and removed in the future).

As a pleasant side effect, this would disambiguate the semantics of var :tag metadata, thereby resolving CLJ-140.

Activity

Hide
Chas Emerick added a comment -

Patch attached (811.diff); change viewable on github here.

This makes calls prefer hints on arg vectors, but preserves fallback to hints on vars, so backwards compatibility is retained. The way is open to only ever use var tags when referring to their contents (rather than using var tags for calls of var contents)...presumably a deprecation/change to be scheduled later that would resolve CLJ-140.

Functions with a vararg signature are explicitly supported. Protocol functions' vars fell right into place.

Show
Chas Emerick added a comment - Patch attached (811.diff); change viewable on github here. This makes calls prefer hints on arg vectors, but preserves fallback to hints on vars, so backwards compatibility is retained. The way is open to only ever use var tags when referring to their contents (rather than using var tags for calls of var contents)...presumably a deprecation/change to be scheduled later that would resolve CLJ-140. Functions with a vararg signature are explicitly supported. Protocol functions' vars fell right into place.
Hide
Aaron Bedra added a comment -

Reviewed code and tested with argos against all contrib libraries that work on 1.3 with no hiccups including core.logic

Show
Aaron Bedra added a comment - Reviewed code and tested with argos against all contrib libraries that work on 1.3 with no hiccups including core.logic

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: