
On Sat, May 2, 2020 at 10:17 AM Terry Reedy <tjreedy@udel.edu> wrote:
True, but that's a bit of an edge case. I'm sure there are other edge cases too - what happens with a 'nonlocal' if it's in a code object outside of a function? (Or in the CPython implementation, what happens with the corresponding cell lookup?) If <me> causes a RuntimeError if used in such a context, or if the compilation of <me> creates some sort of reference that simply doesn't work outside of a function, it'd be fine.
2. Python does name resolution on function bodies when called. If early binding of <me> were possible, it would be an exception.
It would have to be a keyword of a sort. Not necessarily an actual keyword, although that would definitely work.
3. Recursion without names is really hard; hence the special head-spinning combinator to do that.
And that's a good reason to have compiler support for it. It would make true recursion simple. (Obviously mutual recursion would still require names.)
4. The post-compile function object address would only be useful for CPYthon, not for implementations that move objects around.
Why? It's an object. It should be possible to reference it.
True, and that would probably only be a small advantage anyway. But it's also a clarity thing, and it means you don't have to name your function inside the function and then remember to rename it. There is another objection though: 6. Decorated functions would behave differently based on whether you call by name or call by <me>. I don't have an answer to that, other than that giving programmers the option isn't a bad thing. People would just have to be aware of the distinction and know which one they want. ChrisA
participants (1)
-
Chris Angelico