From: Jeff Carter <jrcarter@acm.org>
Subject: Re: Modular types inside records
Date: 2000/10/21
Date: 2000-10-21T00:00:00+00:00 [thread overview]
Message-ID: <39F1C21D.4E0AF2DB@acm.org> (raw)
In-Reply-To: 8FD4BD4F4Pablo@213.25.200.9
"Pawe� Niewiadomski" wrote:
> generic
> type item_type is private;
> type mod_n_max is mod <>;
> package queues is
> type queue is tagged private;
> function empty (q: queue) return boolean;
> function full (q: queue) return boolean;
> procedure add (q: queue; item: in item_type);
> procedure remove (q: queue; item: out item_type);
> private
> type arr is array (natural range <>) of item_type;
> procedure move_to_0 (var: out natural);
> procedure move_to_last (var: out natural; values: in arr);
>
> type queue is tagged record
> values: arr (0..mod_n_max'modulus-1);
> tail: mod_n_max:=0;
> head: mod_n_max:=1;
> end record;
> end queues;
As you have probably found out, this won't work very well, since your
array is indexed by Natural and your index variables are Mod_N_Max. You
can put a bunch of type conversions in your code to work around this,
but it would be clearer to define
type Arr is array (Mod_N_Max) of Item_Type;
I have no idea why you have included the procedures Move_To_0 and
Move_To_Last in the private part.
--
Jeff Carter
"I waggle my private parts at your aunties."
Monty Python & the Holy Grail
next prev parent reply other threads:[~2000-10-21 0:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-21 0:00 Modular types inside records Pawe� Niewiadomski
2000-10-21 0:00 ` Robert Dewar
2000-10-21 0:00 ` Pawe� Niewiadomski
2000-10-21 0:00 ` Jeff Carter [this message]
2000-10-21 0:00 ` Pawe� Niewiadomski
2000-10-23 0:00 ` Robert A Duff
2000-10-23 0:00 ` Pawe� Niewiadomski
2000-10-24 0:00 ` Robert A Duff
2000-10-25 1:50 ` Nick Roberts
2000-10-25 0:00 ` Pawe� Niewiadomski
2000-10-27 22:05 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox