From -2243610709923995458
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e94695845965b249
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-12-10 08:58:39 PST
Path: sparky!uunet!mcsun!sunic!hagbard!loglule!jbn
From: jbn@lulea.trab.se (Johan Bengtsson)
Newsgroups: comp.std.c++
Subject: Re: Zero-length structures and pointer comparisons
Message-ID: <5347@holden.lulea.trab.se>
Date: 10 Dec 92 14:52:18 GMT
References: <1992Dec9.133956.29659@lth.se>
Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
Lines: 44
X-Newsreader: TIN [version 1.1 + PL8]

Dag Bruck (dag@seldon.control.lth.se) wrote:
: In <comp.std.c++> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
: >
: >What I propose is that we define a *standard library function* which computes
: >a total ordering on pointers.
: >
: >int compare_pointers(const void *, const void *);
: >    /* Returns negative, zero, or positive in the same manner as strcmp().
: >       Perhaps in the interests of tradition and unreadability it should
: >       be called ptrcmp() instead of compare_pointers() :-) */

: Suggested semantics: for any pointers p and q:

: 	p == q   <=>   ptrcmp(p,q) == 0

: 	p != q   <=>   ptrcmp(p,q) != 0

: 	ptrcmp(p,q) < 0   <=>   ptrcmp(q,p) > 0

I think ptrcmp() is a good way to resolve this issue.

There is only one possible remaining weakness (I think):

Any environment that relies on pointer translation (swizzling) to
transport objects between executing processes will have difficulty
maintaining a common total ordering for the pointers (IDs) of
objects within those processes (Jim Adcock pointed this out).
Examples include OODBMS and distributed systems.  Code relying
on ptrcmp() may be unportable to those environments.

Should those environments be required to (somehow) provide special
ptrcmp() functions, that look at some object ID (not memory address)?
What if a program uses more than one pointer swizzling scheme (e.g.
distributing some objects over communication channels, and storing other
objects in an OODBMS)?  Is it the users job to provide the ordering
between those different object spaces?

Anyone have a good solution for this?

-- 
--------------------------------------------------------------------------
| Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
| Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
--------------------------------------------------------------------------


