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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6232d4984b20be17 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-23 14:30:07 PST Path: supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!news.litech.org!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!newsfeed.cwix.com!sjc-peer.news.verio.net!news.verio.net!sea-read.news.verio.net.POSTED!not-for-mail Newsgroups: comp.lang.ada From: Brian Rogoff Subject: Re: Implementing an elegant range type. In-Reply-To: <99ggfl$14lpr$1@ID-25716.news.dfncis.de> Message-ID: References: <3ab6442f.0@silver.truman.edu> <7nst6.593482$U46.17851651@news1.sttls1.wa.home.com> <3ab66f83.0@silver.truman.edu> <99ggfl$14lpr$1@ID-25716.news.dfncis.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Fri, 23 Mar 2001 22:29:01 GMT NNTP-Posting-Host: 206.184.139.136 X-Complaints-To: abuse@verio.net X-Trace: sea-read.news.verio.net 985386541 206.184.139.136 (Fri, 23 Mar 2001 22:29:01 GMT) NNTP-Posting-Date: Fri, 23 Mar 2001 22:29:01 GMT Organization: Verio Xref: supernews.google.com comp.lang.ada:6028 Date: 2001-03-23T22:29:01+00:00 List-Id: On Thu, 22 Mar 2001, Nick Roberts wrote: > "Chad R. Meiners" wrote in message > > Of course that is the standard solution of making an ADT range type which > > is entirely independent of Ada's ranges. I have always found this > solution > > unsatifying since it is adds too much complexity to the code that makes > use > > of it. In essence you want ranges to be first class citizens of the language. I feel your pain. One of the most frustrating things about Ada is the inability to have write code which uses the pleasant built in Ada syntax. > For example, the operator I want to use is "in" and not "Length". Yup. > What is always possible is: > > procedure Reserve_Switches (Lo, Hi: in Switch_Number; ...) is > subtype Relevant_Switch is Switch_Number range Lo..Hi; > begin > ... > if S1 not in Relevant_Switch then ... > ... > for S2 in Relevant_Switch loop > ... > etc... > > Given the suggested ADT Switch_Range, the first two lines could have been: > > procedure Reserve_Switches (Which: in Switch_Range; ...) is > > subtype Relevant_Switch is Switch_Number range Which.Lo .. Which.Hi; > > I realise this is not quite the nirvana you wish for, but I think it goes a > long way towards addressing your actual requirements, without the need for > any really new (and potentially confusing) idioms. I like Chad's solution better, and contrary to the opinions of another poster I don't think it's a kludge, though of course it would be nice if Ada allowed us to handle ranges more flexibly. -- Brian