Is there a historical reason why (inc) and (dec) overflow instead of
automatically promoting from Integer to Long when crossing
Integer.MAX_VALUE or Integer.MIN_VALUE? The latter would be consistent
with (+) and (-).

user=> (inc Integer/MAX_VALUE)
java.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0)
user=> (dec Integer/MIN_VALUE)
java.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0)
user=> (+ 1 Integer/MAX_VALUE)
2147483648
user=> (- Integer/MIN_VALUE 1)
-2147483649

user=> (.getClass (+ 1 Integer/MAX_VALUE))
java.lang.Long

Here is what the docs say. If this is intentional it might be worth
noting in the docs.

-------------------------
clojure.core/inc
([x])
  Returns a number one greater than num.

I'm using Clojure 1.1 alpha (most recent commit is
2098f5d57ecf3affb09a4cdaf2e01ad4de861eef), java build "1.6.0_13-
b03-211"
--~--~---------~--~----~------------~-------~--~----~
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