function - what it for ? 
Author Message
 function - what it for ?

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] ?



Wed, 17 Apr 2002 03:00:00 GMT  
 function - what it for ?

Quote:

> 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



Wed, 17 Apr 2002 03:00:00 GMT  
 function - what it for ?

Quote:


>> 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)

--

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.



Thu, 18 Apr 2002 02:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC++ calling fortran function and fortran function calling a c++ function

2. Calling functions from functions from functions ...

3. converting C++ Function to Clarion 5 Function

4. Replace standard MESSAGE function in C4 with own message function

5. Clarion function prototypes for SPGP pgp wrapper functions

6. What might be equivalent clarion function for vb function IIF()

7. counter function : How works the Set attribute function

8. VI Logger functions dont appear on Labview Function Palettes

9. Passing variables to user functions of Clipper functions

10. what is the equivalent function or combination of functions for the following ASYST code

11. Using Timer functions in parallel with VISA functions

12. Call Library Function - Function not found in library

 

 
Powered by phpBB® Forum Software