|
![]() |
|
I’ve been having some fun with Factor lately both learning their very fun new way to code and also expanding my brain with their new concepts. I just stayed up until 5am hacking on this pathetically small little script. What this little bit of factor contains is the start of a project I’m calling Idiopidae after this burrowing spider I like. It’s kind of like noweb but done so that I don’t have to cram my source inside my book or put my book inside my source. Instead, Idiopidae will allow me to put special import and export statements in my LyX source and my project’s source and then it’ll figure out how to merge them into the final output for the book. The thing is, that 70 or so line script does a ton of stuff that you might not notice:
The same file in Ruby was a big hack job that didn’t do any parsing so it wasn’t quite as smart. Now, this damn file took me about 7 hours to write, and it took me probably months to get even that far with Factor. Not really because Factor’s hard, but mostly because I didn’t have any time at all to play with it apart from reading code. Forcing myself to work on a project like this will help me learn faster (I hope). Some things that I’m finding very nice about Factor is the listener and the error checking. The listener is kind of like Factor’s workbench (or the irb you always wanted). The error checking, while at first hard to decipher, helps you spot places where in FORTH you’d be screwed like unbalanced branches and invalid stack effects. Both of those helped me get my head around my code until I was easily fixing very weird bugs with a little thought. Thanks to the #concatenative channel on irc.freenode.org and especially littledan who gave me a sweet chunk of code that was the basis of this file. Those guys totally rock. |