←back to thread

160 points leontrolski | 5 comments | | HN request time: 0.319s | source
1. nemoniac ◴[] No.41887341[source]
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-ad...

replies(3): >>41887390 #>>41887410 #>>41888115 #
2. pansa2 ◴[] No.41887390[source]
That 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.

3. asplake ◴[] No.41887410[source]
I sometimes think it would be fun to do “do: ... where:/while/until”, wherein the “where” part does local bindings.
replies(1): >>41887890 #
4. tpoacher ◴[] No.41887890[source]
there 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/

5. ◴[] No.41888115[source]