Of what use is 'lambda'???

Gareth McCaughan Gareth.McCaughan at pobox.com
Wed Oct 11 16:29:49 EDT 2000


Tom Krehbiel wrote:

> Its been a long time since I worked with lisp, but my memory is that
> the deference between define and lambda is the closer. I thought
> define created a closer and lambda didn't, which means there is
> a significant difference. The lambda command lets you save
> pieces of code that you want to use in-line while define performs
> a call and its associated overhead.

No. Dead wrong, I'm afraid.

In Scheme, DEFINE! and LAMBDA both create closures.
In Common Lisp, DEFUN and LAMBDA both create closures.

In neither case is there any difference in respect of
inline-ness, except that LAMBDAs probably get inlined
more often on account of (1) more often having the
definition provably local to its place of use, and (2)
often being simpler. Well, I suppose there's one other
difference: in Common Lisp, you can use DECLARE to say
that you'd prefer a DEFUNed function to be inlined,
whereas there isn't anything quite equivalent for
anonymous functions.


-- 
Gareth McCaughan  Gareth.McCaughan at pobox.com
sig under construc



More information about the Python-list mailing list