I’ve been trying to learn more about DCGs, and, while looking at the blanks predicate from the library dcg/basics, I noticed that what corresponds to the DCG rule blanks --> []. is translated into blanks(A, B) :- A=B.. My question was this: would it not be simpler to move the unification into the rule head and instead translate the DCG rule into blanks(A, A).? I really want to grok DCGs, so I would appreciate any pointers you all could provide.
?- use_module(library(dcg/basics)).
true.
?- listing(blanks).
dcg_basics:blanks(A, B) :-
blank(A, C),
!,
D=C,
blanks(D, B).
dcg_basics:blanks(A, B) :-
A=B.
true.
For reference, the following is the output I get from running swipl --version: SWI-Prolog version 9.2.9 for arm64-darwin.