I hate writing parsers, but much of the work Allison's asked me to do to revise the PMCs in Parrot has required modification and extension of a parser written in Perl 5 to turn our little language for describing PMCs into compilable C code.
The other day I realized that I could take 65 lines of generated code and turn it into 1 line of generated code by smartening the parser and re-using a function we already had elsewhere. It works for built-in PMCs, but I think there may be a failure case for dynamic PMCs (though fixing that is fairly easy and will provide a nice speed improvement there too).
After thinking about the problem for a while, I decomposed the problem into a couple of function calls that transformed the data I had into the data I needed. I didn't actually write the functions; I merely wrote their names, passed in their arguments, and received the data they returned. After dinner, I started writing the functions.
Everything went well, until I realized that I had to keep looking back and forth at the functions and de-facto signatures (this is Perl 5 code) to remember what I passed in and what I received.
Score one for explicit signatures like you find in C.
Wow, next you'll be applauding static typing?
Re:blink
chromatic on 2008-02-01T07:44:22
Even only the names of the returned values would have been sufficient.
Re:blink
TeeJay on 2008-02-01T14:18:55
Pod ?