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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6232d4984b20be17,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-19 09:42:33 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!nntp.newsfirst.net!newshub.more.net!news.more.net!silver.truman.edu!150.243.170.1 From: "Chad R. Meiners" Newsgroups: comp.lang.ada Subject: Implementing an elegant range type. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: <3ab6442f.0@silver.truman.edu> Date: Mon, 19 Mar 2001 11:45:56 -0600 NNTP-Posting-Host: 150.243.160.9 X-Trace: news.more.net 985023692 150.243.160.9 (Mon, 19 Mar 2001 11:41:32 CST) NNTP-Posting-Date: Mon, 19 Mar 2001 11:41:32 CST Xref: supernews.google.com comp.lang.ada:5859 Date: 2001-03-19T11:45:56-06:00 List-Id: There are certain times that I have wanted to pass ranges as a parameter to subroutines, for example being able to write, "Register_Slots (75..4242);" which of course isn't directly allowed. The solution I came up with is to declare a null type that doesn't take up any memory so that I can create array type of the ranges I want as in the example below. type Nothing is null record; for Nothing'Size use 0; type Integer_Range_Type is array (Integer range <>) of Nothing; Thus I could declare an array, "Integer_Range : Integer_Range_Type (Integer);", and use it to pass array slice which would contain the range data. Example: "Register_Slots (Integer_Range(75..4242));" The problem I am encountering is that when I declare a variable with a range as large as Integer_Range's I get a Storage_Error which doesn't make much sense since if Integer_Range's range is something smaller than 2**20 elements, Integer_Range'Size equals 8 for all cases which I expect should be true even for the large cases since the elements of the array have no size. I am using GNAT 3.13p on WinNT. Has anyone used a similar approach for representing ranges or have any advice on getting around the Storage_Error for large ranges? Thank you, -Chad R. Meiners