From: Francisco Javier Loma Daza <Francisco.Loma@isotrol.com>
To: comp.lang.ada@ada.eu.org
Cc: "'comp.lang.ada@ada.eu.org'" <comp.lang.ada@ada.eu.org>
Subject: RE: Implementing an elegant range type.
Date: 21 Mar 2001 14:00:37 +0100
Date: 2001-03-21T14:00:37+01:00 [thread overview]
Message-ID: <mailman.985179677.16398.comp.lang.ada@ada.eu.org> (raw)
El 20 Mar 2001 15:17:29 -0500, Beard, Frank escribi�:
>
> -----Original Message-----
> From: Chad R. Meiners [mailto:crmeiners@hotmail.com]
>
> >> Why not just write:
> >>
> >> type Integer_Range is record
> >> First, Last : Integer;
> >> end record;
> >>
>
> > For example, the operator I want to use is "in" and not "Length".
> > I want to be able to write "If x in Switches_To_Be_Reserved'Range then
> ..."
>
> Whether you use Mark's example above, or pass in the First and Last
> as parameters, you can still write the following:
>
>
> Assuming "Reserved_Range : in Integer_Range", as the formal argument
> passed in.
>
> if x in Reserved_Range.First .. Reserved_Range.Last then ...
>
>
> or, using Range_First and Range_Last as the formal parameters:
>
> Range_First : in integer;
> Range_Last : in integer;
>
> if x in Range_First .. Range_Last then ...
>
>
> I agree it might be slightly more elegant to pass a single parameter
> so that the statement would be:
>
> if x in Reserved_Range then
>
> but you're only saving one parameter, since "in" works for discrete types.
>
> Frank
This is an interesting way to do range operations. I would like to
do this one:
function Iterator(this: Container.Object) return Container.Range;
declare
r: Container.Range := Iterator(list);
begin
for x in r'Range loop
Process(Item(list, x));
end loop;
end;
...... even better
Process(list(x)); -- :-)
next reply other threads:[~2001-03-21 13:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-21 13:00 Francisco Javier Loma Daza [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-03-20 20:17 Implementing an elegant range type Beard, Frank
2001-03-19 17:45 Chad R. Meiners
2001-03-19 18:38 ` Mark Lundquist
2001-03-19 20:50 ` Chad R. Meiners
2001-03-22 22:20 ` Nick Roberts
2001-03-23 22:29 ` Brian Rogoff
2001-03-20 4:48 ` Dr Adrian Wrigley
2001-03-20 15:31 ` Robert A Duff
2001-03-21 1:21 ` Dr Adrian Wrigley
2001-03-21 3:58 ` Brian Rogoff
2001-03-21 22:55 ` Chad R. Meiners
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox