[racket] circular lists are not lists or sequences

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Dec 10 10:42:22 EST 2012

list? means 'inductively constructed' data. 


On Dec 10, 2012, at 10:21 AM, David Van Horn wrote:

> On 12/10/12 10:14 AM, Matthew Flatt wrote:
>> We did change `in-list' to add a `list?' guard, so the behavior is as
>> intended. Maybe we need a new `in-' sequence constructor that works as
>> long as pairs appear for as far as you demand sequence elements?
> 
> Yes, an `in-pairs' seems right to me.  I can submit a pull request if that design is OK.
> 
> (I guess I'm a little surprised that `list?' returns false for a circular list since a circular list never falsifies the list definition given in the docs.)
> 
> David
> 
> 
>> At Mon, 03 Dec 2012 18:12:51 -0500, David Van Horn wrote:
>>> I have some code that's been broken somewhere between 5.1.1 and git
>>> HEAD.  The issue seems to be either that circular lists no longer are
>>> considered lists by `list?', or `in-list' has added a `list?' check (and
>>> circular lists were never `list?').
>>> 
>>> In any case, these are the kinds of things I would expect to work, but
>>> don't.  Is this a bug?
>>> 
>>>  > (for/first ([y (shared ((x (cons 1 x))) x)]) y)
>>> for: expected a sequence for y, got something else: #0='(1 . #0#)
>>>    context...:
>>> 
>>> /Users/dvanhorn/Documents/git/racket/collects/racket/private/for.rkt:451:2:
>>> make-sequence
>>> 
>>> /Users/dvanhorn/Documents/git/racket/collects/racket/private/misc.rkt:87:7
>>> 
>>>  > (for/first ([y (in-list (shared ((x (cons 1 x))) x))]) y)
>>> in-list: contract violation
>>>    expected: list?
>>>    given: #0='(1 . #0#)
>>>    context...:
>>> 
>>> /Users/dvanhorn/Documents/git/racket/collects/racket/private/for.rkt:551:2:
>>> in-list
>>> 
>>> /Users/dvanhorn/Documents/git/racket/collects/racket/private/misc.rkt:87:7
>>> 
>>> Thanks,
>>> David
>>> ____________________
>>>   Racket Users list:
>>>   http://lists.racket-lang.org/users
> 
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121210/02d0a717/attachment.p7s>

Posted on the users mailing list.