From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Possible for Ada 2020: "Cursors" for Arrays
Date: Tue, 04 Jun 2013 08:19:00 +0200
Date: 2013-06-04T08:19:00+02:00 [thread overview]
Message-ID: <b15f6kFrfs6U1@mid.individual.net> (raw)
In-Reply-To: <55016aa4-4d69-4fd9-a2c9-a7eb7d3b00c5@googlegroups.com>
On 13-06-04 03:09 , Shark8 wrote:
> In a few threads a few people have expressed a desire
> to be able to initialize Arrays based on some formula
> usually including the indices. In order to do this we
> need some sort of "cursor"-type/attribute.
Maybe...
> So, let us propose a cursor-attribute so that some array
> type, T1, defined as
> type T1 is Array( 1..10 ) of Integer;
> could have a variable initialized as follows:
> V1 : T1:= (others => T1'Cursor'Index)
> resulting in V1 getting (1,2,3,4,5,6,7,8,9,10);
I think it would be better to build this ability from syntax similar to
the quantified expressions - "for all/some I in <range> => ...". To
avoid ambiguities when the array elements are Boolean we should use a
new keyword instead of "all" or "some". I would also not put this after
"others", but directly as an "array_component_association":
V1 : T1 := (for each I in T1'Range => I);
But this would make yet another useful word ("each") reserved... Perhaps
we can do without any keyword:
V1 : T1 := (for I in T1'Range => I);
> My question: does this look reasonable, or is it
> just superfluous?
Superfluous, yes, perhaps with the exception of some corner cases such
as initializing large systematic arrays during pre-elaboration. But nice
to have, why not.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2013-06-04 6:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-04 1:09 Possible for Ada 2020: "Cursors" for Arrays Shark8
2013-06-04 6:19 ` Niklas Holsti [this message]
2013-06-04 14:18 ` Shark8
2013-06-04 19:27 ` Niklas Holsti
2013-06-04 20:47 ` Adam Beneschan
2013-06-06 8:58 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox