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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!sdd.hp.com!decwrl!ucbvax!IBM.COM!NCOHEN From: NCOHEN@IBM.COM ("Norman H. Cohen") Newsgroups: comp.lang.ada Subject: Abstraction of variable size vectors (Corrected) Message-ID: <9008021525.AA10630@ajpo.sei.cmu.edu> Date: 2 Aug 90 14:58:57 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: Ref: INFO-ADA Digest Volume 90 Issue 148 (Wed, Aug 1, 1990) Item #1 It took me a while to figure out what Louis-Simon Binette was trying to do. As I understand it, he is trying to imitate Ada arrays with his own private type, specifying the index and components as generic parameters. He needs to store descriptor information--upper and lower bounds of his imitation arrays--but these values may come from outside the index subtype. For example (by analogy to a null string), the index subtype may be Positive, the lower bound may be one, AND THE UPPER BOUND MAY BE ZERO. The solution is simply to pass the index BASE type rather than the index SUBtype as the generic actual parameter: generic type Element_Type is private; type Index_Base_Type is (<>); Index_Subtype_Lower_Bound, Index_Subtype_Upper_Bound: in Index_Base_Type; package Vector_Manager_Template is type Vector is limited private; ... private type Vector is record Vector_Lower_Bound, Vector_Upper_Bound: Index_Base_Type; ... end record; end Vector_Manager_Template; The index subtype bounds are passed as generic parameters so that when a Vector value is created with specified bounds, the package can check whether the bounds are compatible with the index subtype. Norman H. Cohen