Gambit Scheme PHP backend, milestone 1: proof of concept

The goal of this release is to mark the milestone 1 (on github, as .tar.gz). I wanted to understand the GVM and to check if compilation to PHP is possible. This is done. While the current gambit-php version is very limited (only a few primitives are partially implemented), it covers all the important functionality:

* boot up: "Hello, World" example
* recursion: factorial, fibonacci, ackermann
* closures: function which return function which return function etc
* continuations: basic return example, yin-yang puzzle

Scheme code and generated PHP code:
http://github.com/olpa/schemevm/tree/milestone1/step-by-step-examples

The second use of this milestone release is a demostration how to start a backend. The package contains the minimal amount of code to compile the examples. Therefore, the code is much easier to understand then the code of a complete working backend.

I coded straightforward. If I saw a way to solve a problem, I used this way without trying alternatives. In the development process "make it work, make it work correctly, make it work fast", I'm on the step zero "experiment if it would work".

One of the consequences is that performance is poor. For example, Ackermann function A(3,9) is 100 times slowed as by gsi-script and 30 times slower as native PHP implementation. The output from yin-yang puzzle is 30 times slower as by gsi-script and 10 times slower as by Guile. However, I'm optimistic and think there is a lot of possibilties for optimization.

The code is developed for PHP 4.4.8 and tested under PHP 3.0.

Categories: scheme

Updated: