I greatly enjoy all your postings about your Prolog-based interpreter for Joy:
https://osdn.net/projects/joypy/scm/hg/Joypy/blobs/tip/thun/...
I impulsively upvote this every time I see it. Thank you for sharing such an interesting project!
Your advice to use CLP(FD) for the semantics of integer math operations was fantastic!
I typically use SWI Prolog but I hope the code is mostly portable. The parser uses a couple of DCGs from the "basics" lib but I think those are also portable or at least simple to re-implement.
The tricky bit might be the semantics of math (and comparison) ops. I've tried two other sets of semantics, one that attempts to perform math operations (and catch the errors if e.g. an arg is a logic var rather than an int) as you go, and another that just builds expression trees (evaluation is delayed) like so:
func(+, [int(A), int(B)|S], [int(A + B)|S]).
Just to point out, in SWI Prolog the ints are "BigNums" while in GNU
Prolog they're machine words (so modular arithmetic, mod 2^32). You
could use Rationals or make up some other semantics. This all gets into
Categorical paradigm programming. http://conal.net/papers/compiling-to-categories/
The same (point-free) expression can be used to develop concrete programs
over various categories: Hardware circuits, partial evaluation,
differentiation, dataflow graphs, and so on.