Here's a code example illustrating the problem I'm having:
https://gist.github.com/1300034 I've simplified it to the bare minimum
necessary to illustrate the problem.

Agree 100% that ints and longs are broken in Java. The hashcode/
equality stuff is messed up. Clojure can try really hard to hide this,
but it can't hide it completely since Java libraries can always return
you Integer objects. The additional complexity added from changing the
types on you isn't worth it IMO.

Here's my proposal for what I think would be better behavior:

1. Clojure boxes ints into Integers rather than convert them into
longs
2. If you wrap the form in "(long ...)", Clojure skips the boxing and
does what it does now. Since this is done explicitly, there's no
confusion about types.

-Nathan


On Oct 19, 7:38 am, Stuart Halloway <stuart.hallo...@gmail.com> wrote:
> > Thanks. I read through that and it didn't quite answer my question. To
> > me it seems more logical that:
>
> > 1. Clojure defaults to longs when you create a new number (with a
> > literal 0, 1, etc)
> > 2. You can create ints by doing (int 0)
> > 3. Clojure never changes the types of things you're using
>
> > I find Clojure's behavior of changing the types of primitive ints to
> > longs highly unusual, and it is causing a lot of pain in upgrading
> > Storm to 1.3.
>
> Integers and longs are going to be painful no matter what because they are 
> broken in Java, e.g.
>
>         Object[] objects = new Object[] {-1, -1L};
>         System.out.println(objects[0].hashCode());
>         System.out.println(objects[1].hashCode());
>
> Clojure avoids this pit by standardizing on longs, which leaves you with the 
> need to specifically request ints when you need them for interop. You can use 
> (int n) hints to select the correct interop method invocation, or box an int 
> if you want to hold on to a value guaranteed to be int.
>
> Can you post a code example that shows a problem you are having?
>
> Stu
>
> Stuart Halloway
> Clojure/corehttp://clojure.com

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