
On Wed, Dec 01, 2021 at 12:26:33PM +0000, Matt del Valle wrote:
If anything I think the symmetry between the proposed '=>' syntax and the arrow syntax for lambdas in other languages (potentially even in python in the future) reduces the cognitive burden significantly, given the there is an equivalent symmetry with their semantics (in both cases the code is being evaluated later when something is called).
There is not as much symmetry as you might think between a hypothetical lambda arrow and the proposed late-bound default arrow. arg => arg + 1 # lambda arg=>expr # late-bound default The first case is (or could be some day...) an actual expression that returns a function object, which we will explicitly call at some point. Or at least pass the function to another function, which will call it. But the late bound default is not an expression, it is a declaration. It declares the default value used for arg. We don't have to call anything to get access to the default value. It just shows up when we access the parameter without providing an argument for it. We certainly don't need to call arg explicitly to evaluate the default. It may be that behind the scenes the default expression is stored as a callable function which the interpreter calls. (I believe that list comprehensions do something similar.) But that's an implementation detail that can change: it might just as well store the source code as a string, and pass it to eval(). Or use some other mechanism that I'm not clever enough to think of, so I shall just call "deepest black magic". There is no *neccessity* for the late-bound default to be a hidden function, and it is certainly not part of the semantics of late-bound defaults. Just the implementation. If you disagree, and still think that the symmetry is powerful enough to use the same syntax for both lambdas and default arguments, well, how about if we *literally* do that? def function(spam=expression, # regular default lambda eggs: expression, # late-bound default ) Heh, perhaps the symmetry is not that strong after all :-) -- Steve