Re: Ada.Containers.Vectors - querying multiple elements
- From: "Randy Brukardt" <randy@xxxxxxxxxxxxxx>
- Date: Fri, 29 Apr 2005 15:26:31 -0500
"Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx> wrote in message
news:1wjh6qsazg3rg$.lupowyuqu0tw$.dlg@xxxxxxxxxxxxx
....
> I wonder if introducing ranges as a type class could mend this. Provided a
> fictitious attribute Enum'Range (0) would return a null-length range, one
> could then create empty arrays without referencing to any concrete index
> bounds. But then Obj'First and Obj'Last could potentially raise
> Constraint_Error, which might appear unpleasant but perfectly consistent.
> Could there be a distributed overhead in the implementations of 'First and
> 'Last then?
Yes, there would be a distributed overhead. For Janus/Ada (the only compiler
for which I can speak definitively), in the general case array bounds are
stored in a descriptor record, along with a dimension length and a pointer
to the data. The dimension length is really redundant; I don't think most
compilers store it separately. In order to be able to represent an array as
you say, all compilers would have to store the dimension length and
presumably a bit mask to specify which bounds are invalid and raise C_E if
explicitly touched. And of course all references to 'First and 'Last would
have to check the bit mask. Not too expensive, but certainly a significant
change to compilers and some additional overhead.
Array indexing in the general case subtracts 'First from the calculated
value, so I don't think it would make sense to allow 'First to be an invalid
value - at least not unless the length of the array was 0 (in which case it
doesn't matter). But adding overhead to array indexing operations is not
going to win anyone friends. :-) More seriously, I think it would be a
non-starter.
You also have the problem of making the range check for any value when one
or the other bound could be invalid. More overhead in a particularly bad
spot.
So I don't think this idea is going to fly.
Randy.
.
- Follow-Ups:
- Re: Ada.Containers.Vectors - querying multiple elements
- From: Dmitry A. Kazakov
- Re: Ada.Containers.Vectors - querying multiple elements
- References:
- Ada.Containers.Vectors - querying multiple elements
- From: Duncan Sands
- Re: Ada.Containers.Vectors - querying multiple elements
- From: Georg Bauhaus
- Re: Ada.Containers.Vectors - querying multiple elements
- From: Jeffrey Carter
- Re: Ada.Containers.Vectors - querying multiple elements
- From: Randy Brukardt
- Re: Ada.Containers.Vectors - querying multiple elements
- From: Jeffrey Carter
- Re: Ada.Containers.Vectors - querying multiple elements
- From: Randy Brukardt
- Re: Ada.Containers.Vectors - querying multiple elements
- From: Dmitry A. Kazakov
- Ada.Containers.Vectors - querying multiple elements
- Prev by Date: Re: Timing Block of GNAT code in milliseconds
- Next by Date: Re: Ada.Text_IO and protected objects (Was: [newbie question] tasks and protected types)
- Previous by thread: Re: Ada.Containers.Vectors - querying multiple elements
- Next by thread: Re: Ada.Containers.Vectors - querying multiple elements
- Index(es):
Relevant Pages
|