Implicit Evaluation with PHP

18 January 2006

PScheme

Yesterday, I mentioned the beginning of CS491, “Advanced Programming with Scheme.” Briefly, the class covers the more advanced side of Scheme and culminates in either a Scheme interpretter or compiler. The first part of the task, due within about the first three weeks, was to build a scanner and parser. So I did. Only instead of taking three weeks, it took about five hours.

I know PHP helped… Much like Scheme, it freed me to think about the problem and not the details of structure or types or any nonsense like that. Of course, I enforced some structure with a complete OOP design and so-far viewless MVC architecture.

As of right now, the scanner and parser work. They may well explode on macros (I haven’t tested) but they’ve handled every piece of ordinary Scheme I’ve handed it.

And because it’s in PHP, it’s trivial to convert it to a web-accessible medium. While I was hoping to be the first web-browser accessible Scheme, I found http://www.geocities.com/markoriedelde/scheme/index.html beat me to it. But as I was reviewing it, the code is purely procedural. It certainly works well, supporting everything I thought to try. But since I have an assignment to do, I’ve got to keep doing mine anyway.

So take a look at my PScheme (Update Aug 21 PScheme has been taken offline) and watch as it develops over the next four months.

Update
Seems PScheme runs only on PHP5. Not sure why. If you play with the sample, you’ll see it retains the structure of the program you give it, but throws away the values. I enabled var_dump in place of my output routines and it is handling everything correctly, so it’s something in the output routines. Just don’t know what and it’s not on the menu tonight to find out.

Update 2
Seems PHP4’s get_class function returns the classname in lowercase. PHP5 returns the actual name. So in the output layer, I converted the calls to get_class with strtolower(get_class(…)) and suddenly the code reconstruction happens. Why, oh why, do web hosts still insist on using PHP4? And with how compatible PHP4 and 5 are, with 6 dropping register_globals and magic_quotes, it’s uptake will be even slower. Blast!

No Comments currently posted.

Post a comment on this entry: