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

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Jun 9 10:34:16 EDT 2011

(1) To create cyclic structs you need mutability in our world. [gensym is 0 assignments, cyclic structs is 1 assignment, and state is N assignments.]

(2) I think the failure should come earlier when a struct isn't mutable. If you agree, you can try to request a feature change. 






On Jun 8, 2011, at 3:20 AM, Marijn wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi Matthias,
> 
> On 06/06/11 16:58, Matthias Felleisen wrote:
>> 
>> 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)
> 
> Ah, yes, thank you, that's what I was looking for.
> 
> `shared' seems to depend critically on `dl' being mutable and fails
> silently when it isn't. For example:
> 
> 
> #lang racket
> 
> ;;; link structure
> (struct _dl (left val right) #:mutable
>  #:property prop:custom-write
>  (lambda (dl p write?)
>    (let ((print (if write? write display)))
>      (display #\()
>      (let loop ((dl dl))
>        (print (_dl-val dl))
>        (let ((right (_dl-right dl)))
>          (if right (begin (display " ")(loop right))
>              (display #\)) )))))  )
> 
> (define (dlist a b c)
>  (shared ((middle (_dl left   b right))
>           (left   (_dl #false a middle))
>           (right  (_dl middle c #false)))
>   middle) )
> 
> (dlist 1 2 3)
> 
> (display (dlist 1 2 3))
> 
> 
> Outputs:
> 
> 
> (2 3)(2 3)(2 3)
> (2 3)(2 3)
> 
> 
> but when #:mutable is removed it fails in display not in shared. Further
> I do not understand why my custom display code is called so often.
> Lastly, I wonder if there is a benefit to specific orderings of the
> shared clauses or not?
> 
> Thanks,
> 
> Marijn
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.17 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk3vItEACgkQp/VmCx0OL2yIswCgtjXleU2h01ABPKy6AYLUd74y
> sVAAoJFx6w4VxEtRiTiXL3NpymO6aDi1
> =K8Ck
> -----END PGP SIGNATURE-----




Posted on the users mailing list.