How to assert DCG clauses?

Wouter Beek <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAE1un7PEbWaUdAFFrW+=aV+1zpur5XA0Jhm_W8wfSW+wro12uA@mail.gmail.com>
Hi all,

Clauses can be asserted:
~~~
?- X =.. [':-',a,b], assert(X), listing(a).
:- dynamic a/0.
a :-
    b.
X = (a:-b).
~~~

DCG clauses cannot be asserted in the same way:
~~~
X =.. ['-->', a, b], assert(X), listing(a).
ERROR: toplevel: procedure `a' does not exist (DWIM could not correct goal)
~~~

How would one assert DCG clauses?

---
Cheers!,
Wouter.

E-mail: [email protected]
WWW: www.wouterbeek.com
Tel.: 0647674624
-------------- next part --------------
HTML attachment scrubbed and removed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.