From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8077d2e20cde67b1,start X-Google-Attributes: gid103376,public From: niewiap@widzew.net (Pawe� Niewiadomski) Subject: Modular types inside records Date: 2000/10/21 Message-ID: <8FD47616EPablo@213.25.200.9>#1/1 X-Deja-AN: 684098207 X-Complaints-To: usenet@tpi.pl X-Trace: news.tpi.pl 972124069 24301 195.117.215.73 (21 Oct 2000 10:27:49 GMT) Organization: tp.internet - http://www.tpi.pl User-Agent: Xnews/03.04.11 NNTP-Posting-Date: 21 Oct 2000 10:27:49 GMT Newsgroups: comp.lang.ada Date: 2000-10-21T10:27:49+00:00 List-Id: I have an assignment to implement a normal, unidirectional queue as a static array of n_max elements. I wanted the array to be "cyclic", namely I wanted to use two variables: head and tail of a modular type within the queue record so that there would be no constraint error unless the array were really full (checked by an appropriate function). If the tail index were on the last element of the array, its value after the incrementation would be 0, and by that time the 0 element of the array would be probably freed. generic type item_type is private; package queues is type queue(n_max: positive) 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; type queue (n_max: positive) is tagged record values: arr (0..n_max); tail: natural:=0; --I want these two be of modular type with head: natural:=1; --a modulus equal to n_max+1 end record; end queues; If you have any idea on how to solve this problem (no dynamic memory allocation, please) I would be grateful for sharing it with me Pawel