Make L2 work properly
This changes a lot of things.
First, we split apart all the register-using opcodes into local and stack
variants, and tear out the register designator stuff. This is ugly, but will be
way faster because the check doesn't need to happen at runtime any more. It's
made slightly less ugly with a real nasty macro.
We also change how the head and first body term in clauses interact. It turns
out the head needs to respect the arity of the first body clause (if it's
larger), and the two clauses need to share local variable register assignments.
Apparently when HAK says "compiled as one unit" in the book he means this.
Would have been nice if he could have explained that, or at least showed an
example that makes use of it so I have a chance of noticing it.
Still to do before we move on to L3:
* Add a few comments to document the stuff added in this commit.
* Rework the query code store to fall at the beginning of the `CODE` section so
we can just have one program counter and interpreter function to rule them
all.
* Consider figuring out the answer extraction process (we basically need to
modify the query compiler to treat all variables as permanent, and keep that
mapping so we can extract them from the stack at the very end).
author |
Steve Losh <steve@stevelosh.com> |
date |
Sun, 17 Apr 2016 21:36:15 +0000 |
parents |
c60cac27a0a7 |
children |
cb324d188513 |
eeeee eeeee eeeee eeee eeeee
8 8 8 88 8 8 8 8 "
8eee8e 8 8 8e 8 8eee 8eeee
88 8 8 8 88 8 88 88
88eee8 8eee8 88 8 88ee 8ee88
Bones is a logic programming library for Common Lisp.
**Bones is still in development, don't actually try to use this for anything
yet. It should be usable by mid-2016.**
* **License:** MIT/X11
* **Documentation:** <http://sjl.bitbucket.org/bones/>
* **Code:** <http://bitbucket.org/sjl/bones/>
* **Issues:** <http://bitbucket.org/sjl/bones/issues/>
![I don't know what that means](https://i.imgur.com/EWPGAHa.gif)
License
-------
Copyright 2016 Steve Losh and contributors. Licensed as **MIT/X11**.