PEP 312 - Making lambdas implicit worries me, surely it's just the name 'lambda' that is bad...

Alexander Schmolck a.schmolck at gmx.net
Mon Mar 3 14:41:50 CET 2003


Stephen Horne <intentionally at blank.co.uk> writes:

> On 02 Mar 2003 23:16:53 +0000, Alexander Schmolck <a.schmolck at gmx.net>
> wrote:
> 
> >Stephen Horne <intentionally at blank.co.uk> writes:
> >
> >> Actually, I've always thought that having separate 'def' and 'lambda'
> >> syntaxes is a bit redundant. In lisp (and a few others) you'd use the
> >> 'lambda' form to do both jobs, rather like (in current Python)
> >> writing...
> >> 
> >>   sum = lambda a, b : a + b
> >
> >Not true, I think. Apart from scheme (which's lispness is often disputed in
> >both lisp and scheme circles).
> 
> Wierd - I've hardly used scheme, but I have looked at it much more
> recently than lisp (not used properly in more than a decade). Still, I
> appologise for the confusion.

To clarify, in scheme, there is only one namespace:

> (define a-var 1)
> (define a-function (lambda () 1))
> a-var
1
> (a-function)
1

in (common) lisp, which has a separate namespace for functions:

> (defvar a-var 1)
> (defvar a-function (lambda () 1))
> a-var
1
> (a-function)
Error: the function a-function is undefined
> (funcall a-function)
1
> ;; this doesn't affect the variable value of a-function
> (defun a-function () 'result)
> (a-function)
'result
> ;; still the same variable
> (funcall a-function)
1

alex




More information about the Python-list mailing list