4 ms·
Python lambdas are just syntactic sugar for creating a function object. The ast can just build a named function and use it in the needed expression.
by joejev 9y ago
Python lambdas are just syntactic sugar for creating a function object. The ast can just build a named function and use it in the needed expression.
- kazinator 9y agoHowever, that approach seems rather backwards compared to having an anonymous function primitive which is used as the basis for the lambda one-line-only sugar, as well as named functions (which simply establish a binding between a name and the anonymous thing).
- aoeusnth1 9y agoWhy should the programmmer care about whether the underlying function is named or not?
- jwdunne 9y agoI imagine some kind of analogue to gensym would work there. The name can be throw away and guaranteed unique in scope. In fact, a lot of SICP examples have you define a function within a function with a name like "iter" for TCO recursion. It'd work like that. Edit: seems like gyka below confirms that's how it works. I should have read on!