C plus Prolog
29 points by KnorrFG
29 points by KnorrFG
By convention, C Plus Prolog files end in the extension .c+p.
To bad they don’t end with “.cpp”…
OT: Is there a tag we can add for logic programming like prolog/datalog?
I found this pretty interesting. I kinda hate C with a passion, but half of what annoys me about it could be fixed with some good meta programming, which this seems to provide. And C undeniably has its advantages, e.g. it runs about everywhere and compiles super fast.
If the author himself wouldn’t explicitly advise you not to use this, I’d definitely toy around with it. Non the less it’s a very cool idea that’s worth being seen.
Cute project.
Some more serious work of integrating logic programming with something else: https://curry-lang.org
I really wish they went for .cpp
as the extension
That said who’s up for adding objc and c++ support so we can get objc++p?
Long time ago I was obsessed with Prolog. I found that if you bend it enough you could implement imperative code (a-la JavaScript) evaluation, still being valid Prolog:
https://github.com/xonixx/prolog-experiments/blob/main/Prolog/interp/interp4.pro#L275
This was super funny, but obviously absolutely useless 🙂
My fun tiny hack was making a small brainfuck interpreter [1]. You could also give it a begin and end state and would try to generate the instructions to accomplish that (as expected, this quickly leads to all kind of issues).
During my PhD I contributed to a large Prolog-based parsing/generation system for Dutch. E.g., this is the chart generator that I wrote together with my PhD adviser:
https://github.com/rug-compling/Alpino/blob/master/Generation/cg.pl
Also wrote quite a few bits in C using SICStus’ binding support to speed up things.