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

SETF and LAMBDAs (semi-serious?)



This was implemented in Maclisp under the name of "destructuring LET".
It raises a number of complicated issues that I don't think we should get
involved in right now.  Note, as just one example, that you were not
consistent with yourself in the examples you give of what it might do.
Your first example 
    (lambda (x)
      ((lambda ((y x)) (y x))
        x))
seems to expect the argument to be a list of two elements, where y
is bound to the first element and x is bound to the second.  In other
words the "pattern" in the lambda-expression is a piece of data acting
as a template.  Unless I misunderstand the example completely, which
is possible since it certainly isn't written in Common Lisp.
In your second example,
    (let (
          ((elt v 0) (length v)))
      v)
the "pattern" in the lambda-expression (a let this time) is a piece of
code describing a location to be stored into.  I won't even go into the
deeper semantic issues raised by your second example; the syntactic
issues are enough to show that it is complicated.

Note that if you add a new special form (a macro) to the language,
rather than redefining existing things such as let and lambda, you
can experiment with various versions of such things in any Common Lisp
implementation, or any other reasonable Lisp implementation, without
any need to change the compiler, interpreter, or run-time.