Hi
Thank you for great support with reference parameters. After more doc
reading i discovered, that (flet or (labels doing just what i wanted.
I miss that in C++ - enclosured functions, ones which executed in
local enviroinment of other.
Now, in fact, about subject of this message.
As i see, lambda expressions is one of base ideas of lisp. So, I
started read about it and that's what I found:
(lambda (x) (+ x 6)) [1]
and
(function (lambda (x) (+ x 6))) [2]
do the same thing - they return a "reference" to some so-called
"closures", which can be called (with funcall) as a functions. If
we'll not take in account the case when parameter for (function is
another function (for example : (function sin) ), what the difference
between [1] and [2] ?
Arseny Slobodjuck <····@altavista.net> wrote:
> As i see, lambda expressions is one of base ideas of lisp. So, I
> started read about it and that's what I found:
>
> (lambda (x) (+ x 6)) [1]
> and
> (function (lambda (x) (+ x 6))) [2]
>
> do the same thing - they return a "reference" to some so-called
> "closures", which can be called (with funcall) as a functions. If
> we'll not take in account the case when parameter for (function is
> another function (for example : (function sin) ), what the difference
> between [1] and [2] ?
There is none. From the HyperSpec entry for the LAMBDA macro:
-----
Description:
Provides a shorthand notation for a function special form involving a
lambda expression such that:
(lambda lambda-list [[declaration* | documentation]] form*)
== (function (lambda lambda-list [[declaration* | documentation]]
form*))
== #'(lambda lambda-list [[declaration* | documentation]] form*)
------
Most people use (lambda ...) or #'(lambda ...). The latter emphasizes
that this a function.
--
Clemens Heitzinger
http://ag.or.at:8000/~clemens
In article <·······························@ag.or.at>,
Clemens Heitzinger <········@ag.or.at> wrote:
>Arseny Slobodjuck <····@altavista.net> wrote:
>
>> As i see, lambda expressions is one of base ideas of lisp. So, I
>> started read about it and that's what I found:
>>
>> (lambda (x) (+ x 6)) [1]
>> and
>> (function (lambda (x) (+ x 6))) [2]
>>
>> do the same thing - they return a "reference" to some so-called
>> "closures", which can be called (with funcall) as a functions. If
>> we'll not take in account the case when parameter for (function is
>> another function (for example : (function sin) ), what the difference
>> between [1] and [2] ?
>
>There is none. From the HyperSpec entry for the LAMBDA macro:
(function (lambda ...)) comes from pre-ANSI Common Lisp. Originally, a
lambda expression was not an expression you could evaluate, it was just a
piece of syntax that could appear either in the function position of an
expression (e.g. ((lambda ...) <parameters>), which would invoke the
function that the lambda expression defines, or in a FUNCTION special form,
which would return that function.
As a convenience, LAMBDA was later made a macro that does this
automatically.
Note that FUNCTION is still necessary when dealing with function *names*.
There's a big difference between
(funcall #'foo)
and
(funcall foo)
--
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.