Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC830713); site snow.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!mcvax!ukc!qtlon!flame!ubu!snow!sahunt From: sahunt@snow.UUCP (Stephen Hunt) Newsgroups: net.lang,net.lang.pascal Subject: Re: Comparing pointers in Pascal Message-ID: <335@snow.UUCP> Date: Wed, 23-Jan-85 13:30:10 EST Article-I.D.: snow.335 Posted: Wed Jan 23 13:30:10 1985 Date-Received: Mon, 28-Jan-85 06:38:34 EST References: <3161@ucla-cs.ARPA> Organization: Computer Science Department, Warwick University, UK Lines: 42 Xref: watmath net.lang:1314 net.lang.pascal:209 [ Even the line eater couldn't eat THREE Shreadded Wheat! ] In ucla-cs!dimare writes:- > 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 <> ...... > 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? > Adolfo > /// Berkley Pascal is quite normal in this respect. Comparisons like less-than are not allowed simply because they are meaningless. When you conjure up two pieces of storage with new(), say x and y in that order, there is no guarantee that y will directly follow x in memory - it may even be at a lower address. I don't understand why you feel it is "cheaper to keep these lists ordered" - I can't envisage a situation where it would be advantageous to know the real order of this type of structure in store. Are you sure you're not confusing a comparison of pointers with a comparison of pointees? If you *really* want to compare pointers I'm sure you will be able to fudge something with the ubiquitous variant records (unions) - but you will have to know how many bytes a pointer variable takes up, and other similarly nasty (and unportable) pieces of miscellany, --- Steve Hunt ... mcvax!ukc!qtlon!flame!ubu!snow!sahunt