From: Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de>
Subject: Re: limited types in libraries
Date: Sat, 13 Dec 2003 12:43:34 +0000 (UTC)
Date: 2003-12-13T12:43:34+00:00 [thread overview]
Message-ID: <brf1hm$5ko$1@a1-hrz.uni-duisburg.de> (raw)
In-Reply-To: mailman.103.1071196111.31149.comp.lang.ada@ada-france.org
ada_wizard@toadmail.com wrote:
: Hmm. I can't see why it would ever be ok to implement "=" and "<" in a
: non-consistent way. Certainly any subprograms provided by the user
: must meet the container's requirements.
Yes, but there might be different requirements in other parts
of a program, which let the programmer _think_ that "=" and "<"
are consistent.
A database's records of persons' addresses might be sorted by
surname, for example. Suppose name(r) returns a Wide_String or
similar for the surname in a record. Then one record is sorted
before another by
function "<" (k1, k2: DB_Record) return Boolean is
begin
return name(k1) < name(k2);
end "<";
(and similarly for ">"). However, two records indicate the same person
if they show the same name and phone number,
function "=" (k1, k2: DB_Record) return Boolean is
begin
return name(k1) = name(k2) and phone(k1) = phone(k2);
end "=";
Then it might be that for j /= 0,
not dbrec(n) < dbrec(n + j)
and not dbrec(n) > dbrec(n + j)
but still
not dbrec(n) = dbrec(n + j)
and this might make sense from the point of view of database records.
So I might have to change my point of view so that I can see the
requirements of the containers or sorting related algorithms, and
understand, in some details, when "=" and "<" will come into play.
(But I might just be confused.)
-- Georg
next prev parent reply other threads:[~2003-12-13 12:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-12 2:28 limited types in libraries ada_wizard
2003-12-13 12:43 ` Georg Bauhaus [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-12-11 15:13 ada_wizard
2003-12-11 17:36 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox