3 ms·
You could argue that this is not merely adding syntax, but also adding the associated semantics. Anyway, if you found this interesting, you might enjoy Eli Ben
by nemoniac 2y ago
You could argue that this is not merely adding syntax, but also adding the associated semantics.
Anyway, if you found this interesting, you might enjoy Eli Bendersky's blog post from nearly 15 years ago where he adds an "until ... do" statement to Python.
https://eli.thegreenplace.net/2010/06/30/python-internals-adding-a-new-statement-to-python/ https://eli.thegreenplace.net/2010/06/30/python-internals-ad...
- pansa2 2y agoThat blog post seems a lot more involved - it adds code to the bytecode compiler as well as to the parser. I suspect that’s mostly because the `until` statement is more complex - but another factor seems to be Python’s change in parsing technology from LL(1) to PEG.
- asplake 2y agoI sometimes think it would be fun to do “do: ... where:/while/until”, wherein the “where” part does local bindings.
- tpoacher 2y agothere is a nice "staticscope" package in python, which acts as a context manager, and does pretty much what you refer to. pretty neat. https://pypi.org/project/scoping/ https://pypi.org/project/scoping/
- deleted 2y ago[deleted]