Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!cornell!batcomputer!itsgw!nysernic!cmx!hilbert!hamid
From: hamid@hilbert.uucp (Hamid Bacha)
Newsgroups: comp.lang.prolog
Subject: Re: Ranges of values in Cprolog
Message-ID: <467@cmx.npac.syr.edu>
Date: 7 May 88 22:15:55 GMT
References: <242@yetti.UUCP> <451@cmx.npac.syr.edu> <944@cresswell.quintus.UUCP>
Sender: usenet@cmx.npac.syr.edu
Reply-To: hamid@logiclab.cis.syr.edu (Hamid Bacha)
Organization: Logic Lab, CIS Dept., Syracuse University
Lines: 46

In article <944@cresswell.quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes:
>In article <451@cmx.npac.syr.edu>, hamid@hilbert.uucp (Hamid Bacha) writes:
>> Try the following:
>> :- op(500, xfx, in).
>> :- op(802, xfx, '..').  % precedence higher than that of '-' to allow 
>> 			% for negative numbers
>In an Edinburgh-compatible Prolog, "-  is a special case; the
>"-" here is the tightest binding operator and is not disabled by
>	:- op(0, fy, -).
>which cancels the usual unary minus.  Thus after doing
>	:- op(400, xfx, ..).
>both
>	X = [-1..2]
>and	X = [2.. -1]
>should be legal.


In C-Prolog (version 1.5) unary '-' is defined as op(fx, 500, -) and does
not bind tighter than operators with higher precedence (lower precedence 
number). It is treated as a special case in that -1 is negative integer 1 
instead of -(1). A simple example using C-Prolog proves it:

C-Prolog version 1.5
| ?- op(400, xfx, ..).
 
yes
| ?- assert(p(-1 .. 2)).
 
yes
| ?- p(-X).
 
X = 1..2 
 

This is clearly different from '..'(-1,2) which Richard claims it should be.
The same behavior is observed with ALS-Prolog (the other system I have 
access to in addition to our own Columbus Prolog and MetaProlog). So my
comment about the precedence of '..' still stands.

>In an Edinburgh-compatible Prolog, +  has no special meaning;
>if + is a unary operator +1 means +(1).  name/2 and number_chars/2 (if it
>exists) are not supposed to accept leading "+" signs either.
 
I agree entirely with you on this point. The thought that entered my mind
when I wrote my comment was that since -1 is treated as negative interger 1, 
wouldn't it make sense to treat its dual +1 as integer 1.