comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: Optimizing Boundary Checks
Date: Sat, 14 Jun 2003 17:20:11 GMT
Date: 2003-06-14T17:20:11+00:00	[thread overview]
Message-ID: <3EEB5934.1000107@attbi.com> (raw)
In-Reply-To: bccpn8$hogis$1@ID-175126.news.dfncis.de

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.

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

But there is one. ;-)  A discrete variable declaration can have an 
explict range in its subtype_indication:

Size: Integer range 0 .. 1000;

There is no way to identify the subtype of Size to use the 'Range 
attribute, but there are times when it would come in handy. If this is 
added to the language, then probably the attributes Object'First and 
Object'Last should also be added for scalar objects.

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;




  parent reply	other threads:[~2003-06-14 17:20 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 [this message]
2003-06-16 11:23           ` Vinzent Hoefler
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