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.

I don't mean to imply that the design choices made were wrong; I know
that Rich et al put a lot of thought and work into these changes. But
I would like to understand why changing the types of ints to longs is
necessary instead of supporting primitive ints as well.

-Nathan


On Oct 18, 2:25 pm, David Nolen <dnolen.li...@gmail.com> wrote:
> 233 messages long thread from June 
> 2010,http://groups.google.com/group/clojure/browse_thread/thread/c8c850595...
>
> David
>
>
>
>
>
>
>
> On Tue, Oct 18, 2011 at 5:00 PM, nathanmarz <nathan.m...@gmail.com> wrote:
> > Hey all,
>
> > I recently started upgrading Storm to Clojure 1.3, and I ran into
> > various issues due to Clojure's treatment of integers and longs. In
> > particular, I have a situation like the following:
>
> > 1. A Java object returns me an int. Let's call this value "v".
> > 2. I put "v" into a map, and pass that map into a Java object
> > 3. I get ClassCastExceptions when that Java object tries to read that
> > Integer and instead gets a Long back
>
> > The error arises due to Clojure's auto-coercion of primitive ints to
> > longs.
>
> > Auto-coercing ints to longs is prone to errors like I ran into,
> > especially when interoperating with Java code. It becomes especially
> > confusing when considering that "Integer" objects do not get coerced
> > to "Long" objects. Also, if Clojure is trying to treat everything as
> > longs, I don't understand why there's an unchecked-divide-int function
> > and not an unchecked-divide-long function.
>
> > What's the rationale behind all this? Why not support both ints and
> > longs? I'm sure this has been discussed before, so feel free to point
> > me to earlier discussions on this.
>
> > -Nathan
>
> > --
> > 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