Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

Currently count() returns an int - should bump that up to a long.

On long overflow, count() should throw ArithmeticException. Also see CLJ-1229.

4 Answers

0 votes
by

Comment made by: slipset

Looking at this, there are some problems like in
clojure.lang.RT#toArray line 1658
where you create a new Object array based on the count of a collection.
It seems as if new Object(link: ) takes an int as a param, so one would have to downcast the long to an int for this to work.

0 votes
by

Comment made by: alexmiller

If you're creating an Object(link: ) greater than 2147483647, you may have other problems. ;)

But yes, this ticket definitely needs a more thorough analysis as to what is affected. In this case, I think if the count is <= Integer/MAX_VALUE, then it should proceed and otherwise should throw an exception.

0 votes
by

Comment made by: slipset

hmmm, this also causes problems wrt java.util.Collection size:
clojure.lang.APersistentSet#size line 164
Where size is specified by

http://docs.oracle.com/javase/7/docs/api/java/util/Collection.html#size()

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1729 (reported by alexmiller)
...