[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LetRec the way you want it IS in Common-lisp
- To: labrea!Gumby%MCC.COM@labrea.Stanford.EDU
- Subject: LetRec the way you want it IS in Common-lisp
- From: Jim McDonald <edsel!jlm@labrea.Stanford.EDU>
- Date: Fri, 8 Apr 88 19:08:52 PDT
- Cc: labrea!Common-Lisp%Sail.Stanford.EDU@labrea.Stanford.EDU
> In common-lisp you can get the reader to do this for you:
> ==> (prog1 nil (setf foo '#1=(a . #1#)))
> ==> (first foo)
> ==> (second foo)
> ==> (third foo)
That was my first reaction, but this creates a global structure.
I think the goal is to get a dynamically generated recursive
structure. You could do something awful like
(let ((foo (eval (read-from-string "'#1=(a . #1#)"))))
but this seems too bletcherous to suggest as a canonical solution.
Perhaps one could extend backquote to include something like the #n=
feature of the reader. (Perhaps this feature is already in backquote
and I don't know about it?) The following unhappy syntax should not
be that hard to implement:
(let ((foo `,=1=(a ,.=1=)))
Someone who cares could improve on it.
To return to the original question:
Assuming that backquote (or whatever) could give you dynamically
created recursive data structures, and that recursive forms in general
are impossible to handle, is there something in-between that you want?