
On Thu, Nov 4, 2021 at 2:29 AM Ethan Furman <ethan@stoneleaf.us> wrote:
One similarity that I don't think has been mentioned yet:
- decorator syntax says, "run me later, after this function is built"
- late-bound argument syntax says, "run me later, just before each function call"
Hmm, I more think of decorator syntax as "modify this function". It runs at the same time that the def statement does, although the effects may be felt at call time (including a lot of simple ones like lru_cache).
Because both mean "run me later" we can leverage the @ symbol to aid understanding; also, because "run me later" can completely change the workings of a function (mutable defaults, anyone?), it deserves more attention than being buried in the middle of the expression where it is easy to miss (which is why I originally proposed the ? -- it stood out better).
One of the reasons I want to keep the latebound vs earlybound indication at the equals sign is the presence of annotations. I want to associate the lateboundness of the default with the default itself; consider: def func(spam: list = []) -> str: ... Which part of that becomes late bound? The [], not the name "list", not the name "spam". So if you want to make use of the at sign, it would end up looking like matrix multiplication: def func(spam: list @= []) -> str: ... def func(spam: list =@ []) -> str: ... rather than feeling like decorating the variable. Is that still valuable enough to prefer it? ChrisA