Detect circular lists in LENGTH
Bug #1171223 reported by
Paul Khuong
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
It would be nice LENGTH of lists could detect circular lists. Currently, we have assembly VOPs to compute LENGTH (… really). It seems to me we could make everything simpler by instead calling to a regular CL function (e.g. %list-length) via a deftransform. There doesn't even have to be a huge penalty to detect circular lists: we can easily call out to CL:LIST-LENGTH once the length is greater than a couple thousand conses.
description: | updated |
description: | updated |
To post a comment you must log in.
On my machine:
(defparameter lst '(1 2 3)) ; => (1 2 3)
(setf (caddr lst) lst) ; => #1=(1 2 #1#)
(length lst) ; => 3
Seems to me this is the expected behaviour. What do you mean by "LENGTH of lists could detect circular lists"? You are not satisfied with the performance of LENGTH? :)