[racket] Reading Graph Structure: read: #..= expressions not allowed in read-syntax mode (??)
-----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-----