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,CTE_8BIT_MISMATCH, MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,6232d4984b20be17 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-21 05:05:40 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!falcon.america.net!sunqbc.risq.qc.ca!news.maxwell.syr.edu!opentransit.net!jussieu.fr!enst!enst.fr!not-for-mail From: Francisco Javier Loma Daza Newsgroups: comp.lang.ada Subject: RE: Implementing an elegant range type. Date: 21 Mar 2001 14:00:37 +0100 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: avanie.enst.fr 985179680 54869 137.194.161.2 (21 Mar 2001 13:01:20 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Wed, 21 Mar 2001 13:01:20 +0000 (UTC) Cc: "'comp.lang.ada@ada.eu.org'" To: comp.lang.ada@ada.eu.org Return-Path: X-Mailer: Evolution (0.9/+cvs.2001.03.19.09.00 - Preview Release) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: supernews.google.com comp.lang.ada:5962 Date: 2001-03-21T14:00:37+01:00 El 20 Mar 2001 15:17:29 -0500, Beard, Frank escribi�: > > -----Original Message----- > From: Chad R. Meiners [mailto:crmeiners@hotmail.com] > > >> Why not just write: > >> > >> type Integer_Range is record > >> First, Last : Integer; > >> end record; > >> > > > For example, the operator I want to use is "in" and not "Length". > > I want to be able to write "If x in Switches_To_Be_Reserved'Range then > ..." > > Whether you use Mark's example above, or pass in the First and Last > as parameters, you can still write the following: > > > Assuming "Reserved_Range : in Integer_Range", as the formal argument > passed in. > > if x in Reserved_Range.First .. Reserved_Range.Last then ... > > > or, using Range_First and Range_Last as the formal parameters: > > Range_First : in integer; > Range_Last : in integer; > > if x in Range_First .. Range_Last then ... > > > I agree it might be slightly more elegant to pass a single parameter > so that the statement would be: > > if x in Reserved_Range then > > but you're only saving one parameter, since "in" works for discrete types. > > Frank This is an interesting way to do range operations. I would like to do this one: function Iterator(this: Container.Object) return Container.Range; declare r: Container.Range := Iterator(list); begin for x in r'Range loop Process(Item(list, x)); end loop; end; ...... even better Process(list(x)); -- :-)