[racket] Reading Graph Structure: read: #..= expressions not allowed in read-syntax mode (??)

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Jun 6 10:58:52 EDT 2011

Do you want something like this: 

#lang racket

(struct dl (left node right) #:transparent #:mutable)

(shared ((middle (dl left   1 right))
         (left   (dl #false 0 middle))
         (right  (dl middle 2 #false)))
  middle)



On Jun 6, 2011, at 10:30 AM, Marijn wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 06/06/11 15:14, Eli Barzilay wrote:
>> 20 minutes ago, Marijn wrote:
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>> 
>>> Hi,
>>> 
>>> why does the following code
>>> 
>>> 
>>> #lang racket
>>> 
>>> (struct _dl (left val right))
>>> 
>>> (define (dlist a b c)
>>>  #1=(_dl #f a #2=(_dl #1# b (_dl #2# c #f))) )
>> 
>> Note that you wrote an infinite piece of code there, which very few
>> implementations would allow you to do.  (It used to be a cute trick in
>> the distant past.)  I've tried a few implementations, and they fail in
>> a much less graceful way: some schemes just got stuck in an infinite
>> loop, and some lisps threw a stack overflow error.
> 
> My understanding is that it is a finite data structure that refers to
> itself. It is supposed to represent 3 nodes/links of a doubly linked
> list where each node points to its neighbours or #f, so really it should
> only be 3 _dl's big...
> 
> Alternatives are to use a letrec with `delay' on `left and `right'
> members, but then a new accessor that wraps `force' will have to be used
> everywhere.
> Finally, mutation can be used to connect links together in the desired
> way. Maybe I'm trying too hard to avoid this simple fix?
> 
> Thanks,
> 
> Marijn
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.17 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk3s5I8ACgkQp/VmCx0OL2xk2wCfVbQuXXg0/zJTwuoPmeu3LL0X
> 4bMAoJSfaNmSQp9p2kXE8IWxLzoWtpSP
> =N7g8
> -----END PGP SIGNATURE-----
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.