comp.lang.ada
 help / color / mirror / Atom feed
From: Vinzent Hoefler <ada.rocks@jlfencey.com>
Subject: Re: Optimizing Boundary Checks
Date: Mon, 16 Jun 2003 13:23:27 +0200
Date: 2003-06-16T13:23:27+02:00	[thread overview]
Message-ID: <bck9e8$i1s1h$5@ID-175126.news.dfncis.de> (raw)
In-Reply-To: 3EEB5934.1000107@attbi.com

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. 
>  You might want to post a request for the feature in Ada0Y to 
>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 
>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 
>language change.  Right now the initial value, if it exists, is part of 
>the declaration of an object.  Again, no particular reason for that, but 
>RM8.3(14) would need to add another exception to its list.  It sure 
>would be nice though, to be able to say:
>
>Size: Integer range
>    Some_Expression..Some_Other_Complex_Expression := 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.

-- 
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.



  reply	other threads:[~2003-06-16 11:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-13 11:49 Optimizing Boundary Checks Preben Randhol
2003-06-13 12:03 ` Erlo Haugen
2003-06-13 12:38   ` Vinzent Hoefler
2003-06-13 12:47     ` Preben Randhol
2003-06-13 13:28       ` Vinzent Hoefler
2003-06-13 12:42   ` Preben Randhol
2003-06-13 12:48     ` Preben Randhol
2003-06-13 13:28       ` Vinzent Hoefler
2003-06-13 13:56         ` Preben Randhol
2003-06-13 14:42           ` Vinzent Hoefler
2003-06-13 15:25             ` Preben Randhol
2003-06-13 15:34               ` Vinzent Hoefler
2003-06-14 10:45                 ` Preben Randhol
2003-06-14 14:59                   ` James Rogers
2003-06-13 13:33       ` Peter Amey
2003-06-13 13:34 ` Martin Dowie
2003-06-13 13:48   ` Vinzent Hoefler
2003-06-13 14:37     ` Martin Dowie
2003-06-13 15:12       ` Vinzent Hoefler
2003-06-14  2:01         ` Jeffrey Carter
2003-06-16 11:23           ` Vinzent Hoefler
2003-06-14  8:34         ` Dmitry A. Kazakov
2003-06-14 17:20         ` Robert I. Eachus
2003-06-16 11:23           ` Vinzent Hoefler [this message]
2003-06-18 20:58             ` Brian Gaffney
2003-06-13 13:45 ` Dale Stanbrough
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox