4 ms·
You are very welcome! I greatly enjoy all your postings about your Prolog-based interpreter for Joy: https://osdn.net/projects/joypy/scm/hg/Joypy/blobs/tip/th
by triska 7y ago
You are very welcome!
I greatly enjoy all your postings about your Prolog-based interpreter for Joy:
https://osdn.net/projects/joypy/scm/hg/Joypy/blobs/tip/thun/thun.pl 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!
- carapace 7y agoYou're very kind. It's unfinished, and I doubt whether it will ever be useful for anything (other than just being kinda neat in and of itself.) I need to deal with compiling loops/recursion/fixpoints. But thanks! I appreciate it. Your advice to use CLP(FD) for the semantics of integer math operations was fantastic!
- mthom 7y agoYou don't mind if I port Thun to Scryer Prolog, do you? With full credit to you, of course. I'd like to include it as an example.
- carapace 7y agoNot at all, that would be awesome. It's GPL'd, have at it. (^_^) 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/ 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.
- felixyz 7y agoHadn't seen this before. How nice that you called it Thun! Warms my heart.
- carapace 7y agoCheers! Manfred von Thun seems like he was a pretty great guy. I wanted to honor him.