Re: How to assert DCG clauses?

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 08/30/2013 10:11 AM, Wouter Beek wrote:
> ?- X =.. [':-',a,b], assert(X), listing(a).

Carlo's suggestion is completely correct.  I'd like to add one
remark though.  I think I'm seeing more and more

	Term =.. [':-',a,b]

or similar constructs.  This is completely equivalent to the
much more readable

	Term = (a :- b).

Even when using =.., there is no need for the quotes
in ':-'.  :- is an atom.  If it was not, a :- b would not
be valid syntax either.  It is an atom because `symbol
characters' glue together just like lower case letters.
So, also \== or =======> are atoms, regardless of whether
or not they are (declared as) operators.

You need =.. iff

	- You do not know the functor name at compile time
   OR
	- You do not know the number of arguments at compile
	  time

In all other cases, you `create' the term by writing it.  I
suspect that the confusion comes from the idea that you want
to `create' a term and therefore you want some `action' to
take place?

	Cheers --- Jan
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.