On Sat, Dec 11, 2021 at 8:07 PM Stephen J. Turnbull <stephenjturnb...@gmail.com> wrote: > > Chris Angelico writes: > > > It's larger than argument defaults, but also smaller: > > Aside: I'm quite confused by your whole line of discussion here, but > I'll let Eric follow up. > > > The overlap with late-bound defaults is the simple case of mutable > > objects that you want to freshly construct every time, but > > ultimately, that's not hugely different from a lambda function: > > Of course it's hugely different from a lambda function. It will be > evaluated at the time of reference, whereas a lambda function will > not, it won't be evaluated until called. (This means that to access a > deferred object without evaluating it, a separate API will be needed, > sort of the dual of function call.)
So it's a lambda function that gets called the moment you touch it in any way. > > (Another theoretical difference is that a deferred expression is > > parsed in the context of its *usage* rather than its *definition*, but > > that would break all manner of things in Python and is quite > > impractical.) > > I'm a little confused by "theoretical" and "parsed". I guess by > "theoretical" you mean that this is a design choice, and by "parsed in > the context" you mean that the expression could be represented in the > deferred object as a string, an AST, or a code object. Please > confirm. > What I mean is that I don't know whether you intend it one way or the other, so I don't know whether it's an actual difference in your proposal, or something that could in theory be. If name lookups in these temporary expressions have to refer to names in the target function, not in their current context, it causes all kinds of problems. Is that your intention? Otherwise, what is x there? ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ZBFMAOLMZKDYEH5ZIYZID4NZMVTCFCRB/ Code of Conduct: http://python.org/psf/codeofconduct/