Open Immortalin opened 4 years ago
From what I understand, the state of dynamic linking in Rust is not great. I don't know how else it might work.
What about passing data structures back and forth without copying? I am trying to do a JIT interpreter with the parser written in Prolog because of its support for DCGs. Any suggestions?
https://github.com/kloudtrader-github/Susie
Prolog parser -> Rust Cranelift JIT code generator
Related #225
Not at all, see http://adventures.michaelfbryan.com/posts/plugins-in-rust/
I am interested in code generation using Cranelift, and it would be great to perform code generation from the Prolog toplevel.. but that's a ways away. I have plenty to do before getting to that point.
Are you asking if I have suggestions for implementing a parser using DCGs? I'm not sure. I think they're equivalent to pushdown automata/context-free grammars, so their suitability depends on the complexity of your language's grammar.
You could interpret data on the heap in the same fashion the WAM does. The heap is a Rust data structure, in src/prolog/machine/heap.rs
. See the Aït-Kaci book for how data is represented.
Direct access to Prolog terms via FFI does not exist in other systems. Instead, a pretty clumsy interface which originated in Quintus Prolog exists in SICStus, SWI, YAP and some more. The clumsiness is due to the possibility to reorganize (GC, atom-GC and some more) Prolog terms at almost any point in time. However, this interface itself produces much too much overhead such that many prefer not to use it at all.
Also, such an FFI leads to code using that FFI. And that is in the rarest case pure code.
I think #1744 addresses this nicely?
Would be great if Scryer can call libraries written in Rust.