[racket] graph-structured syntax

From: David Herman (dherman at ccs.neu.edu)
Date: Mon Feb 21 11:18:34 EST 2011

Any chance someone has an answer to my question below?

Thanks,
Dave

On Feb 14, 2011, at 4:42 PM, David Herman wrote:

> One more data point:
> 
>> (eval (read (open-input-string "#1=(sin #1#)")))
>    datum->syntax: cannot create syntax from cyclic datum: #0='(sin #0#)
> 
> So that's another clue: it looks like Racket goes to pretty great lengths to prevent the compiler from receiving cyclic AST's.
> 
> Anyway, it would be good to know if there's a place in the docs where this is spelled out.
> 
> Dave
> 
> On Feb 14, 2011, at 4:21 PM, David Herman wrote:
> 
>> I've never been fully acquainted with the graph reader, so I did a little REPL-experimenting and doc-hunting. It appears Racket is pretty conservative about where it allows you to use graph syntax:
>> 
>>> (define x '#0=(foo . #0#))
>>   read: #..-expressions not allowed in read-syntax mode
>> 
>> I imagine this is because cyclic AST's are Really Really Scary:
>> 
>>   #0=(sin #0#))
>> 
>> But I can't quite figure out where, if anywhere, graph-structured S-expressions *are* allowed in the Racket syntax. Certainly, you can use them for a programmatic read:
>> 
>>> (read (open-input-string "#0=(foo . #0#)"))
>>   #0=(foo . #0#)
>> 
>> But is there no place in the surface syntax where you can ever use the graph syntax? Is the `shared' library the only declarative syntax for creating cyclic data structures?
>> 
>> Is this a pretty straightforward restriction that was already done in Common Lisp, or did they allow wild-and-wooly, unrestricted uses of cyclic AST's that (educated guess...) result in undefined behavior by the compiler?
>> 
>> Dave
>> 
>> PS Happy Valentine's Day!
>> 
>> 
>> _________________________________________________
>> For list-related administrative tasks:
>> http://lists.racket-lang.org/listinfo/users
> 
> 
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users




Posted on the users mailing list.