Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Q] - colon operator (:) in SWI Prolog

646 views
Skip to first unread message

Young U . Ryu

unread,
Apr 7, 1995, 3:00:00 AM4/7/95
to
[Posted on 7 April 1995]

While reading the SWI Prolog manual (and checking with current_op/3), I found
':' is defined as an operator, but could not find its use or definition.

:- op(600, xfy, ':')

Can anyone explain what's the use of it?

Thanks in advance.

Young


+-------------------------------------------------------------------+
| Young U. Ryu JO 4.4, P.O.Box 830688 |
| Assistant Professor of MIS 2061 N. Floyd Road |
| School of Management Richardson, Texas 75083-0688 |
| University of Texas at Dallas U.S.A. |
| |
| Fax: 214-690-2799 Internet: ryo...@utdallas.edu |
+-------------------------------------------------------------------+

Johan Dahl

unread,
Apr 8, 1995, 3:00:00 AM4/8/95
to
In article <ryoung.16...@utdallas.edu>, ryo...@utdallas.edu (Young
U . Ryu) wrote:

> [Posted on 7 April 1995]
>
> While reading the SWI Prolog manual (and checking with current_op/3), I found
> ':' is defined as an operator, but could not find its use or definition.
>
> :- op(600, xfy, ':')
>
> Can anyone explain what's the use of it?
>
> Thanks in advance.
>
> Young
>
>

Many newer Prologs define this as a binary operator even if they don't
implement it's use, which (if I remember right) is with different
namespaces.

If you have to predicates both called foo in two different namespaces a
and b, you can call the two foo's with a:foo(...) and b:foo(...).

If someone is more sure than I he/she is probebly more correct.
--
Johan Dahl Johan...@ling.lu.se
Department of Lingvistics and Phonetics
University of Lund
Sweden

Dave Sharpe

unread,
Apr 10, 1995, 3:00:00 AM4/10/95
to
In article <Johan.Dahl-08...@venus.ling.lu.se> Johan...@ling.lu.se (Johan Dahl) writes:
>In article <ryoung.16...@utdallas.edu>, ryo...@utdallas.edu (Young
>U . Ryu) wrote:
>
>> [Posted on 7 April 1995]
>>
>> While reading the SWI Prolog manual (and checking with current_op/3), I found
>> ':' is defined as an operator, but could not find its use or definition.
>>
>> :- op(600, xfy, ':')
>>
>> Can anyone explain what's the use of it?
>>
>> Thanks in advance.
>>
>> Young
>>
>>
>
>Many newer Prologs define this as a binary operator even if they don't
>implement it's use, which (if I remember right) is with different
>namespaces.
>
>If you have to predicates both called foo in two different namespaces a
>and b, you can call the two foo's with a:foo(...) and b:foo(...).
>

You maybe right about the namespaces. However, I use the colon
as a component seperator for tuples (e.g. [1:2 , 1:3] is a list of
2 pairs).

I picked this up from reading someone elses code. My question is
am I using the colon naivly? I do not want any namespace
checking, plus I do want portable code (it works for SWI and Quintus).

>If someone is more sure than I he/she is probebly more correct.
>--
>Johan Dahl Johan...@ling.lu.se
>Department of Lingvistics and Phonetics
>University of Lund
>Sweden

>.
>.

*
* " 'Concept' is a vague concept."
* Ludwig Wittgenstein
* David Sharpe
* e-mail: j9...@unb.ca

Joachim Schimpf

unread,
Apr 11, 1995, 3:00:00 AM4/11/95
to
In article 007F...@utdallas.edu, ryo...@utdallas.edu (Young U . Ryu) writes:
>
>While reading the SWI Prolog manual (and checking with current_op/3), I found
>':' is defined as an operator, but could not find its use or definition.
>
> :- op(600, xfy, ':')
>
>Can anyone explain what's the use of it?
>

Operator declarations just say something about _syntax_. This one just
allows you to write a:b instead of :(a,b) and saves you three keystrokes.
That's all! It does not attach any magical meaning to the colon, so
a:b is just the compound term :(a,b) and per se just as meaningless
as foo(a,b).


And in article 02...@UNBVM1.CSD.UNB.CA, Dave Sharpe <J9...@UNB.CA> writes:
>
>You maybe right about the namespaces. However, I use the colon
>as a component seperator for tuples (e.g. [1:2 , 1:3] is a list of
>2 pairs).
>
>I picked this up from reading someone elses code. My question is
>am I using the colon naivly? I do not want any namespace
>checking, plus I do want portable code (it works for SWI and Quintus).
>

Don't worry. As long as you don't pass your colon-terms to built-in
predicates that interpret them in a special way, it is _you_ who
decides what your colon-terms "mean".


---------------------------------------------------------------------------
Joachim Schimpf Email joa...@ecrc.de
European Computer-Industry Research Centre Phone +49 89 92699 111
Arabellastrasse 17, D-81925 Munich, Germany Fax +49 89 92699 170

0 new messages