Re: #' and lambda



In article <Lr3Hf.548096$084.324960@attbi_s22>,
Brian Downing <see-signature@xxxxxxxxx> wrote:

Having the LAMBDA macro makes one think that evaluating LAMBDA itself
returns a function object, which makes the ((lambda ...) ...) syntax
seem really out of place - if it evaluates its CAR, why doesn't
anything else?

The reason this isn't much of a problem is that ((lambda ...) ...)
syntax is virtually never used any more. It was used decades ago,
before LET was created, but now it has little practical use (I can't
think of any reason to use it offhand). Maybe there are some macros
that have some reason for expanding into a call to a lambda rather than
a LET expression -- there are some slight differences in the effect of
declarations at the head of the body (which is why LET is no longer
simply a macro that expands into a call to the corresponding lambda
expression, as it was in MACLISP).

(That being said, I usually wind up leaving the sharpquote off lambda
without even thinking about it. :-)

As a corollary of what I said above, in modern code (LAMBDA ...) is
never used without being preceded by sharpquote. So there seems to be a
redundancy. All the other uses of #' are necessary to indicate how the
function name should be evaluated -- as a function name or with ordinary
expression evaluation -- but there was no "ordinary expression
evaluation" for a lambda expression. Since LAMBDA was available as an
operator name, they decided to just use it to conflate this redundancy.

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages

  • Re: Method annotation and anonymous functions
    ... anonymous functions and anonymous closures (so def and lambda could have ... the same syntax but lambda would create a closure, ... class Foo ...
    (comp.lang.ruby)
  • Special keyword argument lambda syntax
    ... This proposal ignores Guido's clear-cut decision that lambda is ... This proposal outrageously suggests a special syntax for in-line ... Allow keyword arguments in function call to take this form: ... numerous proposals for alternative syntax. ...
    (comp.lang.python)
  • Re: Anonymous methods, blocks etc. (Cont. default block params)
    ... The syntax here is just ugly. ... * -> is not a common construct in any language that I know of to represent anonymous function declaration, while lambda is. ... in my opinion -> as an operator is not as elegant as other ruby constructs such as things like: ... Perl, but many of those same people are very happy that you did not pull over things from Perl like ...
    (comp.lang.ruby)
  • Re: lambda (and reduce) are valuable
    ... The most significant problem with Python's lambda is that it's billed as an anonymous function, when it's really an encapsulated expression. ... to become even more similar to comprehension syntax: ... The scope of what can be contained in the expression comprehension is exactly the same as what can be contained in a list/generator comprehension, so why not capitalize on the parallelism? ...
    (comp.lang.python)
  • Re: Extending define with where clause
    ... > parallel to lambda*, which implements automatic handling of keyword ... "where" clause is used that the new syntax really matters. ... introduced with the help of let, letrec, letrec*, or named let -- are ...
    (comp.lang.scheme)