Fantastic work! Datalog/Prolog are old-yet-futuristic technologies that I wished every developer knew about, as it solves a lot of problems in very elegant ways (as attested to by this post).
I noticed you (assuming you're the author) used what looks like a non-traditional Datalog syntax – which makes sense to me as, IMO, Datalog/Prolog desperately need first-class support for a record-like syntax to finally break into mainstream. Is there any prior work to this syntax, or did you just develop it as you needed it?
There's a proposal due to the prolog-commons initiative for a dictionary-like object (that is also implemented in SWI Prolog, I believe).
And in Prolog you can, of course, just trivially use your own term structure for item-values:
p([ item : "value", ... ])
You could even use JSON-like terms in Prolog (with maybe a little help by the op/3 directive to sort out parsing priorities):
A_Prolog_Term = {
x: y,
z: [a, b, {1, d} ]
}
But the more fundamental approach IMHO would be to use nested knowledge-base terms:
p(
q(whatever).
r(X) :- q(X).
).
As pioneered in the 1980s for attribute grammars, using ^^ and other special graph tokens as nested "implies" operator, though (see "definite-clause translation grammars").
Agreed on the niceness of the keyword syntax, I would very much like to have than in Prolog too. SWI-Prolog has record-like data structured called dicts (IIRC) but you can't use them directly as clause heads the way the article does.
Comments
Fantastic work! Datalog/Prolog are old-yet-futuristic technologies that I wished every developer knew about, as it solves a lot of problems in very elegant ways (as attested to by this post).
I noticed you (assuming you're the author) used what looks like a non-traditional Datalog syntax – which makes sense to me as, IMO, Datalog/Prolog desperately need first-class support for a record-like syntax to finally break into mainstream. Is there any prior work to this syntax, or did you just develop it as you needed it?
There's a proposal due to the prolog-commons initiative for a dictionary-like object (that is also implemented in SWI Prolog, I believe).
And in Prolog you can, of course, just trivially use your own term structure for item-values:
You could even use JSON-like terms in Prolog (with maybe a little help by the op/3 directive to sort out parsing priorities): But the more fundamental approach IMHO would be to use nested knowledge-base terms: As pioneered in the 1980s for attribute grammars, using ^^ and other special graph tokens as nested "implies" operator, though (see "definite-clause translation grammars").Agreed on the niceness of the keyword syntax, I would very much like to have than in Prolog too. SWI-Prolog has record-like data structured called dicts (IIRC) but you can't use them directly as clause heads the way the article does.