Deferred expressions (was Re: Lambda as declarative idiom)

Nick Coghlan ncoghlan at
Tue Jan 4 04:31:37 EST 2005

Steven Bethard wrote:
> Nick Coghlan: def-from syntax [4]
> (def f(a) + o(b) - o(c) from (a, b, c))
> (def x * x from (x))
> (def x from ())
> (def*a, **k) from (*a, **k))
> ((def x(*a, **k) from ()) for x, a, k in funcs_and_args_list)

After a bit more musing, this is definitely my preferred syntax. I'd call it a 
'deferred expression' rather than an anonymous function, though. The name change 
may seem minor, but it changes the emphasis of the feature from how it's 
implemented to what it is useful for (i.e. deferring evaluation of an expression 
until call time).

It's also conducive to a clean no-argument syntax - simply make the 'from' claus 
optional when the argument list is empty.

'def' and 'from' are already keywords, so there shouldn't be any compatibility 

Michael Spencer's idea of using 'for' instead of 'from' was quite interesting, 
but the use of 'for' without a corresponding 'in' feels a bit misleading :)


Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia

More information about the Python-list mailing list