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

Daniel Dittmar daniel.dittmar at sap.com
Mon Mar 3 06:46:22 EST 2003


Gary Stephenson wrote:
> In Clipper 5 and it's derivatives ( Xbase++, Visual DB, VO,  Flagship,
> Harbour, ... ), lambda style thingies are referred to as
> "codeblocks", and have the declaration syntax.:
>
>      b = {|x,y| x+y }
[..]
> Is there some fundamental difference between the two that I've failed
> to appreciate?  Or are codeblocks only so popular in Xbase++ because
> the rest of the language is so impoverished in comparison to Python?
> Or is the codeblock syntax superior enough to make the construct more
> accessible to "lesser minds".

It can't be seen from your example, but if they are anything like Smalltalk
code blocks, then you can have multiple statements in one block. Whereas
lambda allows only a single expression.

Also, that lambdas act as closures is quite new, so there wasn't that much
that you could do with them.

There are also other ways to get a callable object which are probably not
available in Clipper:
- object.method yields a callable object
- def __call__ (self): makes all objects of a class callable.

Daniel







More information about the Python-list mailing list