8 comments

[ 2.9 ms ] story [ 27.3 ms ] thread
I'm almost certain this was already posted, but cannot find it in the history. I've definitely read it before. It's a bit disappointing, he ends up writing a preprocessor that translates his code into python, which doesn't really feel like a legitimate claim on implementing c-like loop syntax.

The context manager stuff is interesting though.

To me this article really shows the power of Lisp more than anything else. I’ve recently started learning about Racket and the freedom it gives you to make your own DSLs on the go with minimal effort is just mind blowing.

Whether we actually want people’s custom macros and DSLs in production is another question, tho.

Yeah, the difference between manipulating the syntax being the intendend way, and it being possible only through hacking and dark magic is rather stark. It's fun to know that it is basically possible to do though, and I didn't know python had these obscure parts (ast manipulation and codecs)
Whether manipulating the syntax is encouraged or only possible through black magic, the basic problem which GP was (I think) referring to stays the same: "modified" syntax may look more elegant to whoever wrote it, but probably makes the code harder to read and understand for whoever has to work with it later (and that may be yourself, a few years down the line). Plus of course this makes it easier for bugs to hide in unexpected places...