From: tmoran@bix.com
Subject: Re: Searching for an object
Date: 2000/08/22
Date: 2000-08-22T00:00:00+00:00 [thread overview]
Message-ID: <N8Ao5.124331$i5.1828900@news1.frmt1.sfba.home.com> (raw)
In-Reply-To: 87vgwte9yo.fsf@moon.mteege.de
I presume you couldn't do
Lastname : array(1 .. N) of String(1 .. 10);
Firstname : array(1 .. N) of String(1 .. 10);
and have separate Find_xxx routines for the different fields
Find_Lastname("Matthias "); -- not found
Find_Lastname("Teege "); -- found
thus making the caller of Find_xxx make the "which field" decision.
If a single Find routine needs to make a decision based on the
particular desired field, then at some level you really do need what
amounts to a set of "if"s or a "case" statement. If you can use a
subscript and index, then the hardware that decides which RAM address
you're accessing can make the decision, eg
type fields is (lastname, firstname);
subtype names is string(1 .. 10);
type name_parts is array(fields) of names;
type Customer is
record
name_part : name_parts;
other_info: other_types;
end record
Cust : Customer;
Cust.name_part(lastname) = "Teege ";
Cust.name_part(firstname)= "Matthias ";
Find(lastname, "Matthias "); -- not found
Find(lastname, "Teege "); -- found
If you can't do that, you could get the compiler to generate an
implicit "case" by using tagged types and dispatching to a particular
Find depending on the field, but that might be overkill.
next prev parent reply other threads:[~2000-08-22 0:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-18 0:00 Searching for an object Matthias Teege
2000-08-21 0:00 ` Gerald Kasner
2000-08-21 0:00 ` Matthias Teege
2000-08-21 0:00 ` Ted Dennison
2000-08-21 0:00 ` Matthias Teege
2000-08-21 0:00 ` tmoran
2000-08-22 0:00 ` Matthias Teege
2000-08-22 0:00 ` tmoran [this message]
2000-08-21 0:00 ` Ted Dennison
2000-08-31 21:55 ` John McCabe
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox