prolog
prolog copied to clipboard
Region-based memory management
Since we took advantage of Go's memory management, we have a lot of pointers and interfaces which are pointers disguised.
This also lets us provide an approachable set of APIs, I hope, but comes with a cost of GC because the GC has to trace all the live terms.
type Term interface {
WriteTerm(w io.Writer, opts *WriteOptions, env *Env) error
Compare(t Term, env *Env) int
}
We might be able to provide a workable set of APIs while implementing a WAM-like region-based memory management.
type VM struct {
termCells []termCell
// ...
}
type Term uint32 // index to termCells
Related issues:
- https://github.com/ichiban/prolog/issues/238
- https://github.com/ichiban/prolog/issues/226
Some articles that might be related: