Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site topaz.ARPA
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!topaz!hedrick
From: hedrick@topaz.ARPA (Chuck Hedrick)
Newsgroups: net.lang,net.lang.pascal
Subject: Re: Comparing pointers in Pascal
Message-ID: <269@topaz.ARPA>
Date: Tue, 15-Jan-85 04:04:01 EST
Article-I.D.: topaz.269
Posted: Tue Jan 15 04:04:01 1985
Date-Received: Wed, 16-Jan-85 05:26:56 EST
References: <3161@ucla-cs.ARPA> <746@loral.UUCP>
Organization: Rutgers Univ., New Brunswick, N.J.
Lines: 26
Xref: watmath net.lang:1258 net.lang.pascal:191

> I just ran into a problem with pointers in Pascal: I have
> two lists of pointers, and I need to find the intersection
> of them. Due to the nature of the problem, it's cheaper to
> keep these lists ordered.
> 
> However, Pascal complains when I try to campare two pointer
> variables with operators different than = and <>:

Yes, the standard says that only = and <> work on pointers.  However in many
implementations, there is a simple dodge that will solve your problem.
According to the standard, ORD is only legal on ordinal types.  However in
many implementations, ORD will work on pointers.  It simply converts it to
an integer.  (Typically it just defeats typechecking.  No extra code is
generated.)  If your implementation is like this, then you can do 

   if ord(x) < ord(y)

This works on the DEC-20, Pyramid, and SUN.  Since it works on both the
Pyramid and the SUN (which are 4.2 systems), I assume it would work on the
Berkeley VAX compiler.  It does not work on the VMS Pascal compiler.  You
should probably segregate any code that uses this into an implementation-
dependent part, since this is a violation of the standard.

Although I may have found you a kludge for this particular case, it is
certainly true that this sort of thing is a problem with Pascal.  I agree
that some form of type cast would be desirable.