Schelog for Gambit
This is a version of Dorai Sitaram's Schelog,
an embedding of Prolog into Scheme, that is adapted for Gambit-C.
I have made the following general changes:
- Fewer calls are made to call-with-current-continuation; when
the continuation is known a priori, it is constructed using closures.
This affects especially %rel and %or with many clauses.
- If all possible argument lists to a %rel are of the same length, then
the formals list is optimized for that number of arguments. (It is still true that calls
to the function generated by %rel can take any number of arguments.)
- Cons cells, rather than vectors, are used to store Schelog variables.
- A so-called "occurs check" is added as an option during unification. The code
to solve the puzzle in
houses.scm, as it is stated, cannot run to completion without it. (Thanks to Fergus Henderson for help with this.)
- Unify has been rewritten to run a bit faster when compiled by Gambit-C.
- Some of the type tests have been separated so more partial knowledge can be used.
- The arithmetic relations have been rewritten.
- The Prolog-style versions of %member and %if-then-else have been enabled.
In addition, some inlining directives have been added to guide compilation.
With these changes, some short benchmarks run four to five times as fast as before.