[Python-ideas] Thoughts on lambda expressions

Ed Minnix egregius313 at gmail.com
Wed Mar 2 19:09:44 EST 2016


Perhaps a better keyword like ``fun`` (in F#, for instance).

Giving ``def`` a new meaning would introduce ambiguities, which would be more trouble than the shorter syntax is worth.

- Ed

> On Mar 2, 2016, at 7:00 PM, Mike Miller <python-ideas at mgmiller.net> wrote:
> 
> 
> On 2016-03-02 15:03, Paul Moore wrote:
>> PS For the record, I dislike the lambda syntax intensely - the odd
>> keyword, the fact that "lambda" is sometimes almost as long as than
>> the expression I'm using, the use of the mid-line colon which is hard
>> to spot, ... So in principle I'm inclined to support "improvement"
> 
> Hmm, can't think of a way to get rid of the colon without it looking like a generator, but perhaps we could tackle the other issues by letting "def" stand in for "lambda":
> 
> 	lambda x: x.y
> 
> 	def x: x.y
> 
> It's shorter, not an esoteric word, and is analogous to a named function definition, reminiscent of javascript.  The lack of name/parens separates it from the standard form.  Doable, but of course its pretty late in the game to be changing lambda, perhaps in Python 4?
> 
> -Mike
> 
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



More information about the Python-ideas mailing list