From bourassa@magma.ca Mon Nov 4 17:13:12 2002 From: Gregory Bourassa To: ciao-users@cliplab.org Subject: Re: curly braces Date: Mon, 04 Nov 2002 17:12:39 +0100 Message-ID: <15814.40055.778902.180734@salmon.ls.fi.upm.es> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7599182658241744467==" --===============7599182658241744467== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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" wrote: >=20 >=20 > Hi people >=20 > 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=20 > has then in its syntax diagrams. >=20 > But I cannot find any explanation of their meaning. >=20 > John O'Gorman > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > Message: Address: Action: > help majordomo(a)clip.dia.fi.upm.es Info. on useful comma= nds > 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 > ciao-users(a)clip.dia.fi.upm.es Send message to list > ---------------------------------------------------------------------------= -- > Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ > ---------------------------------------------------------------------------= -- >=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D 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 l= ist ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ ----------------------------------------------------------------------------- --===============7599182658241744467==-- From jorgemp@icmc.usp.br Tue Nov 5 11:42:19 2002 From: "Jorge M. Pelizzoni" To: ciao-users@cliplab.org Subject: RE: curly braces Date: Tue, 05 Nov 2002 11:41:25 +0100 Message-ID: <15815.41045.591652.710920@salmon.ls.fi.upm.es> In-Reply-To: <15814.40055.778902.180734@salmon.ls.fi.upm.es> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5345550717855051425==" --===============5345550717855051425== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=20 {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=20 ?- {a, b, c} =3D '{}'(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 >=20 >=20 > John, >=20 > 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. >=20 > Regards. >=20 > Gregory Bourassa >=20 > On Nov 04, "John O'Gorman" 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 > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D 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 l= ist ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ ----------------------------------------------------------------------------- --===============5345550717855051425==--