Clojure

(take-nth 0 coll) spins wheels on Solaris

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: Backlog
  • Component/s: None
  • Labels:
    None

Description

(take-nth 0 (range 5)) is a silly thing to do, but if you're anything like me then it inexorably fills heap space and cpu time by an infinite number of RMI calls.
I'm running Clojure 1.1.0-master-SNAPSHOT under Java 1.6R17 on Solaris 10 and I watched it fill up to 56GB
I think it should raise an exception instead but Im too new to clojure to recommend one. Sorry
Cheers
Simon

Activity

Hide
Assembla Importer added a comment -

bhurt said: [file:awDmNUpz4r34FheJe5aVNr]: Proposed patch to fix this ticket

Show
Assembla Importer added a comment - bhurt said: [file:awDmNUpz4r34FheJe5aVNr]: Proposed patch to fix this ticket
Hide
Assembla Importer added a comment -

stu said: Hi Simon,

If you set the print-length you can prevent runaway sequences from trying to print. Try the following, and if still blows up please re-open or file a new bug:

(set! *print-length* 10)
 (take-nth 0 (range 5))

Cheers,
Stu

Show
Assembla Importer added a comment - stu said: Hi Simon, If you set the print-length you can prevent runaway sequences from trying to print. Try the following, and if still blows up please re-open or file a new bug:
(set! *print-length* 10)
 (take-nth 0 (range 5))
Cheers, Stu
Hide
Assembla Importer added a comment -

bhurt said: I think the real problem is that (take-nth 0 some-list) is invalid. It's nonsensical in a deep way- take every 0th element? If you glanced at my patch, all I did was validate the arguments and throw an exception if the n argument is not positive, rather than returning an infinite list. I mean, a similar problem shows up if you do (count (take-nth 0 (range 5))).

Show
Assembla Importer added a comment - bhurt said: I think the real problem is that (take-nth 0 some-list) is invalid. It's nonsensical in a deep way- take every 0th element? If you glanced at my patch, all I did was validate the arguments and throw an exception if the n argument is not positive, rather than returning an infinite list. I mean, a similar problem shows up if you do (count (take-nth 0 (range 5))).

People

  • Assignee:
    Unassigned
    Reporter:
    Anonymous
Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: