Thats a great feature as well! It is very good not to clutter the code with
magic constants, but to be able to name them in a sane way.
Thank you all again,
/Linus
Den 5 dec 2011 18:38 skrev "David Powell" :
>
>
> On Mon, Dec 5, 2011 at 5:29 PM, Linus Ericsson <
> oscarlinuserics...@gmail.com>
On Mon, Dec 5, 2011 at 5:29 PM, Linus Ericsson wrote:
> David and Stu to the rescue. Of course that's the way to do it.
Not sure if this is what you want, but Clojure 1.3 introduced ^:const.
This lets you store a primitive constant value:
(def ^:const hash -3750763034362895579)
Then you ca
David and Stu to the rescue. Of course that's the way to do it.
Thank you both,
/Linus
2011/12/5 David Nolen
> You can't store primitives in vars. But you can cast their contents to
> primitives with (long ...) (int ...) etc
>
> David
>
> On Mon, Dec 5, 2011 at 12:16 PM, Linus Ericsson <
> osc
You can't store primitives in vars. But you can cast their contents to
primitives with (long ...) (int ...) etc
David
On Mon, Dec 5, 2011 at 12:16 PM, Linus Ericsson <
oscarlinuserics...@gmail.com> wrote:
>
>
> 2011/12/5 Stuart Sierra
>
>> > (side note: what is different between Long/MAX_VALUE
2011/12/5 Stuart Sierra
> > (side note: what is different between Long/MAX_VALUE and the
> > function call (Long/MAX_VALUE)?
>
> None. Both are syntax sugar for (. Long MAX_VALUE)
>
>
> > It seems like unchecked-multiply doesn't like vars, but thats surprising.
> > What am I doing wrong here?
>
> (side note: what is different between Long/MAX_VALUE and the
> function call (Long/MAX_VALUE)?
None. Both are syntax sugar for (. Long MAX_VALUE)
> It seems like unchecked-multiply doesn't like vars, but thats surprising.
> What am I doing wrong here?
unchecked-multiply only does unchecked a
I try to do multiplication where overflowing is expected and the result
should be handled "modulo" ie the multiplication results in a truncated
long.
user> (unchecked-multiply (Long/MAX_VALUE) (Long/MAX_VALUE))
1 ;;is ok and expected
also
classificator.fnvhash> (unchecked-multiply Long/MAX_VALUE