Thank you!

On Nov 30, 2012, at 11:35 PM, dmiller <dmiller2...@gmail.com> wrote:

> Patched in master branch.
> 
> Clojure 1.5.0-master-SNAPSHOT
> user=>
> user=> (defn bar [^Double d] d)
> #'user/bar
> user=> (defn baz [^System.Double d] d)
> #'user/baz
> user=> (bar 1.2)
> 1.2
> user=> (baz 1.2)
> 1.2
> user=> (defprotocol FP (foo [_]))
> FP
> user=> (extend-protocol FP System.Double (foo [d] d))
> nil
> user=> (foo 1.2)
> 1.2
> 
> You can now type hint with double, Double and System.Double.
> 
> One should keep in mind that this is the CLR, not C# (or the JVM).  Thus, 
> int, Int32, System.Int32 and float, Single, System.Single.
> 
> Note  that a type hint such as ^System.Int32 x  is actually using the symbol 
> System.Int32 as the value for :tag -- that is how the LispReader works. 
> However, if you were to put :tag metadata on programmatically and actually 
> use the type System.Int32 -- well, that should work also. 
> 
> 
> -David
> 
>> 
>> On Thursday, November 29, 2012 11:02:19 AM UTC-6, ffailla wrote:
>>> 
>>> I have discovered some odd behavior when type-hinting fns with 
>>> ^System.Double:
>>> 
>>> user=> (defn bar [^System.Double d] d)
>>> #'user/bar
>>> user=> (bar 1.2)
>>> 2.35293190771409E-316
>>> user=> (bar 1)
>>> 2.35069794048985E-316
>>> 
>>> The same behavior occurs when extending double via extend-protocol or 
>>> extend-type:
>>> 
>>> user=> (defprotocol FooProto (foo [_]))
>>> user=> (extend-protocol FooProto System.Double (foo [d] d))
>>> nil
>>> user=> (foo 1.2)
>>> 2.25126584588049E-316
>>> 
>>> Any ideas?  Thanks.
>>> 
>>> -Frank Failla
> -- 
> 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

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