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

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



James McCartney <asynth@io.com> writes:

> 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.
> 
> 
> I assume something simple could be done where you have a syntax to
> bind symbols, and then access their bindings. Does Lisp do this
> already? or is graph data just written as Lisp code and eval'ed?

S-expressions can represent a direct acyclic graph since such a graph
can be topologically sorted so you don't have to refer back to a
previously defined piece.

Common Lisp has a reader trick that allows you to do such
backreferencing and can represent general graphs.

'(1 2 #1=(3 4) #1#)


-- 
Jane - Daria? Come on, the neighbors are starting to talk.
Daria - Um... good. Soon they'll progress to cave drawings and civilization 
will be on its way.