Hello,
I've experimented with Scheme-to-PHP compilation using GVM (milestone announce below). Now I'd like to implement a complete backend. I need guildelines how to do it. Among questions:
* Which primitives should be implemented?
* How to generate the complete set of r5rs functions from the primitives?
* How to integrate the backend to Gambit? Is it possible to select a backend from command line?
* What is the recommended way to distribute a backend?
Thanks!
Now the announce:
Gambit Scheme PHP backend, milestone 1: proof of concept http://github.com/olpa/schemevm/tree/milestone1 http://github.com/downloads/olpa/schemevm/gambit-php-20110208-milestone1.tar...
The goal of this release is to mark the milestone 1. 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.