Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site gitpyr.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!gatech!gitpyr!robert
From: robert@gitpyr.UUCP (Robert Viduya)
Newsgroups: net.lang,net.lang.pascal
Subject: Re: Comparing pointers in Pascal
Message-ID: <19@gitpyr.UUCP>
Date: Tue, 15-Jan-85 02:01:49 EST
Article-I.D.: gitpyr.19
Posted: Tue Jan 15 02:01:49 1985
Date-Received: Thu, 17-Jan-85 13:11:52 EST
References: <3161@ucla-cs.ARPA>
Organization: Georgia Tech, Atlanta
Lines: 63
Xref: watmath net.lang:1264 net.lang.pascal:194

> 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 <>:
> 
>  > Script started on Thu Jan 10 23:30:45 1985
>  > Warning: no access to tty; thus no job control in this shell...
>  > e[2:1] c p.p; pi p.p
>  > program blah (input, output);
>  > var
>  >   x,y: ^integer;
>  > begin
>  >   new(x);
>  >   if x  > end.
>  > Thu Jan 10 23:27 1985  p.p:
>  > E 6 - < not allowed on pointers - only allow = and <>
>  > e[2:2] 
>  > script done on Thu Jan 10 23:31:03 1985
> 
> I'm not trying to do arithmetic with pointers, I only need
> to order them. I think this restriction is excessive. Is there
> a good reason for it? Would Modula-2 behave in the same way?
> Is it that Berkely Pascal is a wacko?
> 

In most Pascal's I've used, the predefined function 'ord' can be used on
pointer variables to return the actual machine address of whatever the
pointer points to (the pointee?).  You might want to try that method.

Or you can be more unportable and do the following:

	program blah (input, output);
	type
		a = record
			case boolean of
				true:	(i : integer);
				false:	(p : ^integer);
		end;
	var
		x,y:	a;
	begin
		new(x.p);
		if x.i