Goran Krampe's HttpView2 web programming framework has a nice utility called MacroProcessor, which provides PHP-ish expansions, as per the class comment:
The above code produces the string 'This code: 3+4 evaluates to: 7.'
I've previously used MacroProcessor to good effect to generate Linux- and Windows-specific Makefiles from templates.
MacroProcessor's code contains a sprinkling of underscores as assignment operators. The code base is small, so it is possible to convert underscores to the ":=" assignment operator by hand, but what fun is that?
What is fun is to do that in Smalltalk. The following is done in Pharo 1.2, which is where I have a copy of MacroProcessor. The starting points were Compiler, RBParser, Decompiler, etc. After poking around - running code in workspaces and exploring their results, looking at test cases - I come to RBConfigurableFormatter>>acceptAssignmentNode: which looks like this:
Ok... And assignmentOperator turns out to be RBAssignmentNode>>assignmentOperator, which is:
Aha! The next step is obvious:
With the above, and a bit more exploratory programming in workspaces, I end up with the following:
Figure 1: Here's what a method looked like originally.
Figure 2: Here's what the method looks like afterwards.
It remains to file MacroProcessor out from the Pharo 1.2 image, then file it into my current working Pharo 1.4 image.