[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can s-exprs represent a graph without eval?



At Thu, 19 Jun 2003 10:26:45 -0700, James McCartney wrote:
> S-exprs can represent trees of data easily. I am wondering if s-exprs, 
> or some other syntax, can be used to represent a graph just on reading, 
> without eval.

Scheme does this already; this:

  #1=(1 . #1#)

Is the same as:

  (define l '(1))
  (set-cdr! l l)

ie a cons pair where the car is the 1 and the cdr is the pair itself.

You use #n= to "bind" a point in the sexp and #n# to refer to that
point in the sexp (where `n' can at least be a string of digits; I
don't know if it can be more).

I don't believe that that this is in R5RS, but PLT Scheme and Chez
Scheme (and probably others) support it.

Robby