On May 11, 2011, at 4:47 PM, David Nolen wrote:

> On Wed, May 11, 2011 at 11:09 AM, Chas Emerick <cemer...@snowtide.com> wrote:
> (defn foo
>   ^String ([] "bar")
>   ^double ([a] 5.6)
>   ([a b] :not-hinted-at-all))
> 
> Given the current implementation I really don't see how this could work. 
> Keeping the old fn type-hint in a separate place from the new primitive type 
> hints is wise until the implementation can actually deliver unified semantics.

Assuming the JVM as it is today (i.e. no fixnums, etc.), is there any potential 
that primitive and non-primitive semantics can be unified?  Is that even 
desirable considering the host?

Even if the answer is 'yes', if one wanted different syntax to correspond with 
different semantics, this is not the most obvious distinction:

^double ([a] 5.6)
(^double [a] 5.6)

My only point with the strawman you quoted is that the hint is for the return 
type, and has nothing to do with that arity's arguments – so, why put it there?

Syntactically (and semantically before they started participating in IFn class 
interface selection), type hints are metadata on the expression following the 
hint, so their current position implies that they relate to arguments.  This is 
more clear with a single-arity declaration:

(defn ^String foo [])
(defn foo ^long [])

Those that understand the nuanced semantic distinction will understand what's 
going on regardless of where the hint is placed; those that don't will think 
the syntactic difference is arbitrary, a just-so difference.

- Chas

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to