
On 2021-10-30 at 18:54:51 -0700, Brendan Barnwell <brenbarn@brenbarn.net> wrote:
On 2021-10-30 18:29, Chris Angelico wrote:
Right. That is a very real difference, which is why there is a very real difference between early-bound and late-bound defaults. But both are argument defaults.
I don't 100% agree with that.
This seems to be the crux of this whole sub-discussion. This whole thing scratches an itch I don't have, likely because of the way I learned to design interfaces on all levels. A week or so ago, I was firmly in Brendan Barnwell's camp. I really don't like how the phrase "default value" applies to PEP-671's late binding, and I'm sure that there will remain cases in which actual code inside the function will be required. But I'm beginning to see the logic behind the arguments (pun intended) for the PEP. As prior art, consider Common Lisp's lambda expressions, which are effectively anonymous functions (such expressions are often bound to names, which is how Common Lisp creates named functions); see https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node64.html for reference. The human description language/wording is different; , but what Python spells "default value," Common Lisp spells "initform." Python is currently much less flexible about when and in what context default values are evaluated; PEP-671 attempts to close that gap, but is hampered by certain technical and emotional baggage. (OTOH, Common Lisp's lambda expressions take one more step and include so-called "aux variables," which aren't parameters at all, but variables local to the function itself. I don't have enough background or context to know why these are included in a lambda expression.)