git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Syntax for one-line "nonymous" functions in "declaration style"


On Fri, Mar 29, 2019 at 7:29 AM Alexey Muranov <alexey.muranov at gmail.com> wrote:
> My idea however was to have it as an exact synonyme of an assignment of
> a lambda. Assignment is an assignment, it should not modify the
> attributs of the value that is being assigned.

Assigning lambda functions to names generally shouldn't be done. Just
use def. You're asking for another way to do a bad thing that has a
better alternative.

There have periodically been proposals for the opposite, which would
take care of some of the alternatives:

def op["double"](x): return x * x

This kind of proposal has its own issues, but I think it has a much
better chance of being accepted than a way of creating and assigning
lambda functions.

ChrisA