3 ms·
The source is almost as interesting as the language. Craziest HTML I have ever seen render so nicely. It's a self-modifying Perl program.
by sjs 15y ago
The source is almost as interesting as the language. Craziest HTML I have ever seen render so nicely. It's a self-modifying Perl program.
- walrus 15y agoThe author of Caterwaul, Spencer Tipping, has a document (which is a self-modifying Perl program itself) explaining the technique. https://github.com/spencertipping/writing-self-modifying-perl/blob/master/writing-self-modifying-perl.pdf?raw=true https://github.com/spencertipping/writing-self-modifying-per...
- Quiark 15y agoAny ideas what is this good for? I'm sure it's a nice intellectual exercise, but does it simplify something or make some cool tricks possible?
- spencertipping 15y agoI originally wrote it for that reason: it's sort of a mind-bending exercise and I wanted to see if it could be done. (The first attempt was actually in Bash, but that didn't work at all.) Since refining the implementation a bit, I've found these scripts to be unexpectedly useful. I mainly use them to encapsulate things like build rules, though now they have an inheritance hierarchy and some standard library functions that I reuse. Because these scripts are self-contained, I can upgrade library code without breaking old projects. The coolest thing about these files, I think, is that they support inheritance from one another and are fairly smart about it. (This feature didn't exist at first, and as a result they were impossible to manage.) If you locally modify one to differ from one of its parents, it makes a note of this and preserves your changes to the modified attributes during upgrades. I use this on the Caterwaul page to provide custom HTML -- most scripts load some Javascript that shows you the attribute table.