CLJ-957: Typehints for variadic methods in deftype fail to compile

105 views
Skip to first unread message

Chris Gray

unread,
Mar 22, 2012, 6:40:28 PM3/22/12
to cloju...@googlegroups.com
Hello,

I noticed that code like the following

(defprotocol ProtocolToTestMethodArgHints
(method-with-multiple-sigs [this ^long arg1 ^boolean arg2] [this ^boolean arg1 ^boolean arg2 ^boolean arg3]))
(deftype TypeToTestMethodHints []
ProtocolToTestMethodArgHints
(method-with-multiple-sigs [this ^long arg1 ^boolean arg2] arg1)
(method-with-multiple-sigs [this ^boolean arg1 ^boolean arg2 ^boolean arg3] arg2))

would cause the compiler to throw an exception. (Basically because
defprotocol kept the typehints and deftype threw them away.)

I decided to fix it by having deftype keep the typehints. I guess it
would also work if we had defprotocol throw them away.

Which solution is "right"? Discuss! :)

Cheers,
Chris

David Nolen

unread,
Mar 22, 2012, 7:17:19 PM3/22/12
to cloju...@googlegroups.com
As far as I know, protocol methods are not meant to be hinted.


--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To post to this group, send email to cloju...@googlegroups.com.
To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.


Chris Gray

unread,
Mar 22, 2012, 8:04:54 PM3/22/12
to cloju...@googlegroups.com
So does that mean that you think the types on protocol methods should
be dropped? Because I'm okay with that solution as well. I prefer
the solution that I've posted because it is simple and works the same
way as typehints on regular functions, but if there's a good reason
not to allow hints on protocol methods, it shouldn't be too hard to
drop them.

Cheers,
Chris

David Nolen

unread,
Mar 23, 2012, 12:59:11 AM3/23/12
to cloju...@googlegroups.com
primitive type-hints have no meaning on protocol fns - as in there is no support at all for it to work. It would be nice to support class type-hints tho.

David
Reply all
Reply to author
Forward
0 new messages