[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Whoops (SETF and LAMBDAs)
I guess I didn't make myself very clear in my previous message,
so I'll try again. First, I'm talking about two related but
distinct things, namely
1.) the lambda calculus
2.) Lisp.
I picked a rather miserable example to illustrate what I want to
do in the lambda calculus, so here's another try. The way I'd
assign a value to an expression like
((lambda (x)
(plus x 1))
2)
is to "evaluate (plus x 1) in an environment where `x' has the
value 2". What I want to do is to extend this to the case where
x isn't an atom. So to evaluate
((lambda ((sin x))
(cos x))
1)
I'd "evaluate (cos x) in an environment where the non-atomic
expression `(sin x)' has the value 1". (I'm not necessarily
claiming that "plus", "sin", "cos", "2", "1", have their typical
meanings--I suppose it depends on what they're bound to.) With
the usual meanings, I'd expect the value of the expression to be
zero, and if we plugged 0 instead of 1 into the lambda, the
result would be ambiguous, but either +1 or -1 should be valid
"interpretations".
In the case of Lisp, I was just thinking of LET as being a
convenient shorthand for LAMBDA. So
(let (
((elt v 0) (length v)))
v)
is equivalent to
((lambda ((elt v 0))
v)
(length v))
(or should that be a "(function (lambda ...))"? Anyway...)
So, is that roughly what MacLisp's "destructuring LET" did?
Something like SETF for lambdas, only without the idea that the
LET actually expanded to a lambda?
Let me also repeat that I'm not seriously suggesting
implementation of this stuff (or non-implementation for that
matter). I'm just interested in toying with the ideas (for now).
Hope that clarifies what I was trying to get across.
-- Will
-------