[CLJ-1294] (vec (range)) causes REPL to hang (infinite loop?) Created: 11/Nov/13 Updated: 11/Nov/13 Resolved: 11/Nov/13
|Affects Version/s:||Release 1.5|
LightTable and CoutnerClockWise
I just typed
in LightTable and it stop working while CPU went to 100%
|Comment by Andy Fingerhut [ 11/Nov/13 5:39 PM ]|
Rene, this is expected to cause an infinite loop. (range) returns a lazy infinite sequence of integers. vec tries to cause the entire infinite sequence to be realized so it can put all elements into a vector. This is not a bug. You asked for an infinite loop, and you got one
|Comment by Alex Miller [ 11/Nov/13 6:10 PM ]|
(range) will yield an infinite sequence. vec will walk the sequence, conj'ing each item onto the vector ... which will do bad things.
While Clojure works well with infinite sequences (an abstraction), the collections like vector support only a finite number of elements.