One of the main changes to 1.3 is that arithmetic operations on longs
do not automatically overflow.

In the early discussions of this new feature, it was pointed out that
people who want overflow capability can use the special "prime"
operators, but that the preferred way to do things would be to write
functions in such a way that you can pass in bigints if you want
overflow.

But it was also pointed out that passing in bigints to ensure overflow
would be a huge performance hit over 1.2 for cases where overflow only
happens sometimes, because this forces bigint math to happen all the
time, which is substantially slower than Clojure's existing strategy
of doing math on longs and only switching to slower bigint math when
overflow actually occurs.

To resolve this, it was proposed that Clojure would use its own BigInt
class rather than Java's built-in.  It would start off as a stub that
forwarded everything to Java's implementation, but would eventually be
converted to a more intelligent interpretation that works more like
Clojure's existing system -- numbers small enough to be represented as
Ints or Longs would be represented that way and benefit from faster
computation.

As far as I know, the stub class was indeed implemented to preserve
the option to make these optimizations, but no one has actually
refined the BigInt class.  I propose that these optimizations should
be done before Clojure 1.3 goes final, because this is a really
important part of ensuring good numeric performance for applications
that were previously taking advantage of Clojure's ability to handle
overflows.  If this isn't done by Clojure 1.3 final, we're going to
end up with a body of code that, by necessity, uses the prime
operators, because the preferred strategy of passing in bigints will
be impractically slow.  If we want to get people to use the idiom of
using non-prime operators and passing in bigints, we need to make sure
this approach performs well for the final release.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to