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


    In order to create circular structure, you have to do something like

    (let ((circular (list 1 2 3 4)))
      (setf (cdr (last circular)) circular)

    I don't know how to do this kind of thing in a purely functional style.

Yes, it's clear that in order to implement a letrec, which would allow
you to express:

  (letrec ((circular (list 1 2 3 circular))

Something would have to be fixed up after the structure was created.
I have no idea how one would best implement this but I would assume
that the compiler would substitute all all appropriate references to
the named object with some sort of forwaring cell, which would be
smashed to point to the whole object after it was created.

I also know of no way that a pure functional program can perform
these fixups.  That's why I thought that it was important for the
system to provide this.

If I'm being totally brain damaged here then I'm sorry.  We can,
after all get back to those messages about &Rest args.

Noone, yet, seems to have said that such a letrec would be a totally
worthless thing.  Equally, noone has been saying things like "well,
it's too late/hard to put it into CL."