Let's start Scheme

2015-03-25

R6RS compliant

Recently, I've improved R6RS compliance on Sagittarius. To check how much improved, I've run the test cases of nausicaa-oopp. Unfortunately, original Github repository seems gone somewhere but if you have it on your local machine, then checkout the revision '26c6994' which it still supported other R6RS implementations.

The library is R6RS portable yet so hard to run. As far as I know, there are only a few implementations which can run the test without raising an unexpected error (Racket and Vicare, I've tested). Now, it's time to add Sagittarius to the list.

Conclusion first, this is the result: https://gist.github.com/ktakashi/d6232d5ac7ae6a5d6fc1

To run the test, I need to patch some libraries. One is getenv and the other one is adding required argument otherwise Sagittarius compiler would raise an error during the compilation. There are couple of failures but these are either too specific test or enhancement of Sagittarius. The error of catch-syntax-violation can be consider test case's bug and some are Sagittarius enhancement. Sagittarius actually doesn't check duplicated bindings on let or letrec. Some are because of eval doesn't inherit current environment. (So the class <n> and <t> can't be seen). The test case itself expects specific value of &syntax's subform slot. It might be better to have some convension but R6RS doesn't specify this. The same goes catch-assertion test cases. The fixnum issue is that on 64 bit environment, Sagittarius uses 62 bits as fixnum (this seems the same on Vicare, so it fails as well).

I've also made an execution option that given script runs strict R6RS mode. Which basically reads all expression ahead and wrap with special syntax so that compiler can expand macro first and compile the expressions.
# Run the `script.scm` on strict R6RS mode
$ sagittarius -r6 script.scm
This mode is similar with the behaviour of Andre van Tonder's expander. Thus the script can contain library in it. Be careful, define-library can't be in it.

Now, I believe I can say, Sagittarius is also the R6RS implementation :) (unless otherwise there's a bug which is always the case.)

No comments:

Post a Comment