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,df40d0d1975a16a6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-16 04:24:58 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!freenix!skynet.be!skynet.be!fu-berlin.de!uni-berlin.de!213.200.246.247!not-for-mail From: Vinzent Hoefler Newsgroups: comp.lang.ada Subject: Re: Optimizing Boundary Checks Date: Mon, 16 Jun 2003 13:23:27 +0200 Organization: JeLlyFish software Message-ID: References: <3EEB5934.1000107@attbi.com> NNTP-Posting-Host: 213.200.246.247 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: fu-berlin.de 1055762696 18935857 213.200.246.247 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:39237 Date: 2003-06-16T13:23:27+02:00 List-Id: Robert I. Eachus wrote: >Vinzent Hoefler wrote: > > > Yes, and finding this *very* useful, it reminds me, I would like to > > have this feature for *every* variable, not just for arrays: > > > > As an example, currently > > > > |x : My_Enum; > > | > > |for i in x'Range loop ... > > > > doesn't work, you have to write > > > > |for in in My_Enum'Range loop > > > > each time. Is there any convincing explanation why it isn't allowed = to > > use the actual type of a variable instead of the type itself? > >No real reason, just no one saw the need for that particular attrbiute.=20 > You might want to post a request for the feature in Ada0Y to=20 >Ada-Comment@ada-auth.org. Perhaps I'll do. But then I would come up with a better justification than just "it comes handy". > > I can imagine situations (especially with subtypes) where it could be > > handy to use the variables' type instead of an explicit type > > specification. > >You will need a better justification than that! Of course. >But there is one. ;-) A discrete variable declaration can have an=20 >explict range in its subtype_indication: > >Size: Integer range 0 .. 1000; Well, IMO that's bad style anyway. >Of course, there is a real useful idiom which would need another=20 >language change. Right now the initial value, if it exists, is part of=20 >the declaration of an object. Again, no particular reason for that, but= =20 >RM8.3(14) would need to add another exception to its list. It sure=20 >would be nice though, to be able to say: > >Size: Integer range > Some_Expression..Some_Other_Complex_Expression :=3D Size'First; Well, as I said, anonymous types are bad style. The reason I would like to have that feature is that sometimes I don't want to iterate over the array of some Index_Type, instead I only want to initialize a part of the array from a Sub_Index_Type. Currently I can write that by specifying the type explicitely, but sometimes I change those types and corresponding variables, so then the code breaks when I forget to change the type specification in the loop. And sometimes I even don't care about the actual variables type name and just want to iterate over it's defined range whatever this currently is. Vinzent. --=20 Parents strongly cautioned -- this posting is intended for mature audiences over 18. It may contain some material that many parents would not find suitable for children and may include intense violence, sexual situations, coarse language and suggestive dialogue.