comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Clayton <phil.clayton@lineone.net>
Subject: Re: initialize an array (1-D) at elaboration using an expression based on the index?
Date: Sun, 24 Oct 2010 15:48:21 -0700 (PDT)
Date: 2010-10-24T15:48:21-07:00	[thread overview]
Message-ID: <ade14be1-de0a-4dfa-a2a5-6009fa6da139@l20g2000yqm.googlegroups.com> (raw)
In-Reply-To: 9df4e5eb-fba7-4e8c-ba44-cd1ad4081d3b@26g2000yqv.googlegroups.com

On Oct 24, 5:40 pm, Shark8 <onewingedsh...@gmail.com> wrote:
> Interesting.
> It doesn't look like it would be very extensible into multidimensional
> arrays though.
>
> Perhaps something like an 'Initialize attribute [on the type, not the
> variables thereof] which would take an Access to Function returning
> that type. It would have to be called only in the case of K :
> Array_Type because K : Array_Type:= (Others => <>) is providing an
> initialization of the default value to all the elements [which is
> unlikely to match the initialization's value].
>
> However, it is the internals of the function which are interesting if
> this route were taken.  The indexings need to be discrete types,
> however they need not be numeric or even all the same type. This
> results in the following being valid:
>   Type A_HighSchool_Letterjacket_Type is Array (Size, Color,
> Character) of Byte; -- A jacket-maker's inventory for letter-jackets.
>
> So we can't have an "array" representing the indicies for use in the
> initialization-function.
> (ex: ---Invalid
>   For Index_1 in Index(1)'Range loop
>     For Index_2 in Index(2)'Range loop
>       For Index_3 in Index(3)'Range loop
>         -- do stuff for calculating the value stored;
>       end loop;
>     end loop;
>   end loop;
> )

Good point.  I think it is ok for multidimensional arrays given the
right interpretation of a "for expression" though.

In fact, it should probably be called a "for aggregate".  It looked
like Adam was suggesting that it would just be another case of
array_aggregate (4.3.3) in the syntax.  So a nested "for aggregate"
would, presumably, work as a subaggregate allowing multidimensional
arrays to handled.

Another way to think about this is that

  (for I in T => F(I))

would be equivalent to and interchangeable with the named aggregate

  (X1 => F(X1), X2 => F(X2), ...)

where X1, X2, ... are the elements of subtype T.  With that view, it
seems a fairly simple extension to the language from a technical
perspective.

Phil



  reply	other threads:[~2010-10-24 22:48 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-15 23:03 initialize an array (1-D) at elaboration using an expression based on the index? Nasser M. Abbasi
2010-10-15 23:31 ` Vinzent Hoefler
2010-10-16  0:16   ` Adam Beneschan
2010-10-16  0:29     ` Nasser M. Abbasi
2010-10-16  1:47       ` Robert A Duff
2010-10-16  1:01     ` Randy Brukardt
2010-10-16 10:08     ` Phil Clayton
2010-10-18 15:03       ` Adam Beneschan
2010-10-19  6:29         ` Randy Brukardt
2010-10-20 20:01         ` Phil Clayton
2010-10-19 16:34     ` Britt Snodgrass
2010-10-19 18:05       ` Jeffrey Carter
2010-10-19 19:00         ` Vinzent Hoefler
2010-11-10 14:33     ` Georg Bauhaus
2010-11-10 15:51       ` Adam Beneschan
2010-11-10 17:19         ` Dmitry A. Kazakov
2010-11-10 18:03           ` Adam Beneschan
2010-11-11  1:07         ` Georg Bauhaus
2010-11-11  8:30           ` Dmitry A. Kazakov
2010-11-11 12:02           ` Robert A Duff
2010-11-11 14:19             ` Georg Bauhaus
2010-10-16  0:52 ` Jeffrey Carter
2010-10-16  0:54 ` Gene
2010-10-16  1:11   ` Vinzent Hoefler
2010-10-21 13:44 ` Chad  R. Meiners
2010-10-24 16:40   ` Shark8
2010-10-24 22:48     ` Phil Clayton [this message]
2010-10-25  2:23       ` Shark8
2010-10-29 23:26         ` Phil Clayton
2010-10-31 18:47           ` Shark8
2010-10-31 21:59             ` Georg Bauhaus
2010-11-01  0:45             ` Phil Clayton
2010-11-01  1:55               ` Shark8
2010-10-30  6:34         ` Brian Drummond
2010-10-31 19:00           ` Shark8
2010-10-31 18:09             ` (see below)
2010-10-31 19:35               ` Shark8
2010-10-31 22:47                 ` (see below)
2010-11-01  0:07                   ` Shark8
2010-10-31 23:21                     ` (see below)
2010-10-31 21:26             ` Brian Drummond
2010-11-12 18:10             ` Randy Brukardt
replies disabled

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