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

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

Robby Findler writes:
> At Thu, 19 Jun 2003 20:19:44 -0400, "Anton van Straaten" wrote:
> > Ever since I first saw it, I've liked the way lazy languages allow you to
> > achieve the same end, e.g. in Haskell:
> > 
> > 	colors = "white" : "grey" : colors
> > 
> > It's a very direct expression of the desired result.
> In theory (although I don't know of any real languages that support
> this well), you could have such expressions in strict languages, too.

Ocaml permits defining recursive values:

  let rec colors = "white" :: "grey" :: colors

> For simple examples like the one above, where the contents of the
> list are visible, it's easy enough to build a macro to construct the
> circular list. I think that it is possible to do better, however,
> with some dynamic checking.

However, Ocaml doesn't let you use any expressions that do any
computation when building a recursive value, I guess to prevent users
from accessing unitialized pointers. You can only use literals,
variable references, and value constructors.

Neel Krishnaswami