What John said is quite true, but not quite complete. Each pair of curly braces actually act as a kind of exceptional predefined unary operator and, just like every other operator in Prolog (whether predefined or not), MEANS but a (very convenient) notational aid for writing terms. So, the meaning of
{a, b, c}
is simply a term of functor '{}' and arity 1 whose ONLY argument is the term
','(a, ','(b, c))
You can attest that by querying
?- {a, b, c} = '{}'(X). ?- functor({a, b, c}, F, A).
Notice that the AND comma (not the ARGUMENT DELIMITER comma) is itself a binary operator that just "happens" to have an associated ','/2 predicate implementing logical conjunction. So, finally cueing in John, the thing is that the DCG "parser" simply "happens" to render a special meaning to '{}'/1 terms. But you are still allowed to render them any other meaning you devise, provided this happens out of the DCG scene.
Cheers,
Jorge.
-----Original Message----- From: owner-ciao-users(a)clip.dia.fi.upm.es [mailto:owner-ciao- users(a)clip.dia.fi.upm.es] On Behalf Of Gregory Bourassa Sent: Monday, November 04, 2002 1:13 PM To: John O'Gorman; Prolog Subject: Re: curly braces
John,
They are used in Definite Clause Grammar (DCG) clauses to enclose a Prolog expression (term) which will not be translated by the grammar translation. As you may know, the DCG clauses are translated into plain Prolog clauses which take care of handling the lists of input tokens over which the grammar will be applied. This saves you writing the list-handling part of things, which can be boring and error-prone. The terms enclosed in curly brackets are included in these translated clauses, but without change. You generally use them to state logical relations about things in the grammar.
Regards.
Gregory Bourassa
On Nov 04, "John O'Gorman" <john.ogorman(a)zombie.co.nz> wrote:
Hi people
Can anyone tell me the meaning of {} in prolog. Claudi Marcus has examples of terms within curly braces in her book. Also Prolog: The Standard has then in its syntax diagrams.
But I cannot find any explanation of their meaning.
John O'Gorman
============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------