I didn't release it was valid to define names with colons in them.
Maybe that shouldn't be allowed. I'd like to be able to specify type
hints using UML-like syntax like the second example from Chas which
was

(defh foo [s:String unhinted-arg {a:int :a}] ...)

On Wed, Aug 12, 2009 at 1:02 PM, tsuraan<tsur...@gmail.com> wrote:
>
>> - There's already a lot of moving parts to type hinting, so adding
>> this optional approach into defn seems like it'd lead to unintended
>> consequences.  That said, there's absolutely nothing wrong with an
>> alternative def form (defh? as in 'define hinted fn') -- there's
>> plenty of them throughout contrib and elsewhere.
>
> Yeah, I tried to slip my change into a place in defn that probably
> wouldn't hurt anything, but I'm still not sure what the full
> consequences of my change are.  I'm far from a clojure expert :)
>
>> - Remember destructuring, and along with that, one of the nice thing
>> about in-place hints, as opposed to a separate definition of expected
>> types, is that the definitions can be sparse, e.g.:
>>
>> (defn foo [{blah :foo #^MyType mt-obj :bar} a b c] ...)
>>
>> It doesn't look like your macro supports hinting destructured args
>> (understandably enough, doing so given the :signatures approach would
>> likely be very difficult).
>
> I didn't put it in yet, but I was thinking of just having nil in the
> type vector for unhinted variables, so you could have
>
> (defn foo {:signature [ String String nil ]} [ a b c ] ...)
>
> and then c wouldn't be hinted.  I hadn't thought of destructuring at
> all; I'm guessing that it could be done with
>
> (defn foo {:signature [{:bar Mytype} nil nil nil]} [{blah :foo mt-obj
> :bar} a b c] ...)
>
> but that's getting pretty ugly on its own.  I'm not sure if it would
> be a win to try to do anything fancy like that.  I'm also not sure
> what the destructuring assignment syntax is for maps right now, so
> what I wrote might be total nonsense, syntactically.  I hope the idea
> is clear, anyhow.
>
>> - The thing I don't like about the current type hints is (IMO) the
>> distracting quality of '#^'.  What about something like:
>>
>> (defh foo [String:s unhinted-arg {int:a :a}] ...) or
>> (defh foo [s:String unhinted-arg {a:int :a}] ...)
>>
>> That's far more visually-appealing to me, and has the nice advantages
>> of being inline in the case of destructuring and supporting sparse
>> hinting easily.  I'll bet the macro would end up being pretty simple,
>> as well.
>
> I'd hate to see somebody do it, but it's currently valid to define
> variables with colons in them, so there could be code out in the wild
> with those definition forms already.  Other than that, I like the
> looks of it.  I think the macro would be easy as well, so long as
> you're comfortable munging variable names :)

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
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