You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Markus, I really liked the simple but effective mi_list3 from the acomip chapter. It's already in difference list form, so it can of course be rewritten using DCGs (and called with phrase/2 to force reduction to [] i.e. true):
I think this DCG form has several really nice features:
Pedagogically, I think it's a beautiful example of semicontext notation, which I'd found confusing.
The optional empty list semicontext (, []) in the first mi_dcg_clause conveniently corresponds to the optional :- true., and the --> corresponds to implication in the usual direction. And it makes it clear that the interpreter itself is just the reflexive transitive closure of some rewriting rules.
It's a nice basis for experimenting with meta-interpreters which make non-trivial use of DCG capabilities. For example, using seq and ... we can write some basic rules in a very readable way:
Hi Markus, I really liked the simple but effective
mi_list3
from the acomip chapter. It's already in difference list form, so it can of course be rewritten using DCGs (and called withphrase/2
to force reduction to[]
i.e.true
):Here's the original for reference:
I think this DCG form has several really nice features:
, []
) in the firstmi_dcg_clause
conveniently corresponds to the optional:- true.
, and the-->
corresponds to implication in the usual direction. And it makes it clear that the interpreter itself is just the reflexive transitive closure of some rewriting rules.seq
and...
we can write some basic rules in a very readable way:I thought this might be a fun addition to the DCG or meta-interpreter chapters, or at least worth sharing!
The text was updated successfully, but these errors were encountered: