comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Clayton <phil.clayton@lineone.net>
Subject: Re: Gnat GPL 2010 available soon (conditional expressions)
Date: Tue, 6 Jul 2010 09:31:05 -0700 (PDT)
Date: 2010-07-06T09:31:05-07:00	[thread overview]
Message-ID: <87dfe70c-fd5b-4b76-8e37-b38539826502@y11g2000yqm.googlegroups.com> (raw)
In-Reply-To: 1wl74eppoqii9$.1oxpbe851z3jk$.dlg@40tude.net

On Jul 6, 8:36 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Mon, 5 Jul 2010 15:47:41 -0700 (PDT), Phil Clayton wrote:
> > On Jul 5, 2:12 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> > wrote:
> >> On Sun, 4 Jul 2010 18:27:04 -0700 (PDT), Phil Clayton wrote:
> >>> In my view, condition expressions are a step in the right direction...
> >>> but I'm the sort of person who wants to write an array aggregate like
>
> >>>   (for I in 1 .. 5 => (for J in 1 .. 7 => (if I = J then 1.0 else
> >>> 0.0)))
>
> >>   (for I in 1..5 => (for J in 1..7 => Float (Boolean'Pos (I = J))))
>
> > Yep, I should have seen that one coming straight back... and taken
> > steps to avoid it :)
>
> BTW, is your construct 1) a macro expansion (as I remember PL/1
> preprocessor also had %for statement alike) and how far are you ready to go
> allowing "for" macros? Loops unrolling? Or else 2) it is an attempt to name
> the components of an array element index.

Definitely the latter...


> In the latter case
>
>    (I, J : others => <an expression involving I,J>)
>    (I : 1..5 => <an expression involving I>)
>    (Odd : 1 | 3 | 5 | 7 => <an expression involving Odd>, others => 0.0)
>    etc
>
> looks to me more consistent with existing Ada, e.g. when Error : others =>
> in exception handlers.

Interesting.  So, considering the difference between

  1.  X : T
  2.  for X in T

My take on Ada is that [1] just declares a new variable X of subtype T
(which may be initialized depending on context) whilst [2] is used
when declaring a new variable X of subtype T and then giving X the
values of T in some specified order, i.e. introducing some iteration
scheme.  If that is a fair assessment of things, then perhaps

  (for I in 1 .. 5 => F(I))

is more in keeping with existing Ada?  (If I'm talking absolute
drivel, please let me know...)


The concept of an order is important because the function F could have
side effects in the above example (though I would not advocate that as
good practice).  However, we would be able to write

  (for I in reverse A'Range => A(I))

to represent the reverse of the array A is perhaps a little confusing.


Also, it really only makes sense to have one variable holding the
array index.  For example, if we could write

  (I, J : 1 .. 5 => ...)

surely I and J would always be equal: there are only 5 elements in the
array.  Having

  (for I in 1 .. 5 => ...)

syntactically rules out multiple variables.

Phil



  parent reply	other threads:[~2010-07-06 16:31 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-16 20:14 Gnat GPL 2010 available soon Stephen Sangwine
2010-06-16 21:24 ` Martin
2010-06-16 21:35 ` Simon Wright
2010-06-18 19:48 ` Albrecht Käfer
2010-06-26 12:04   ` lekktu
2010-06-26 21:04     ` anon
2010-06-26 21:41       ` lekktu
2010-06-27  3:33         ` anon
2010-06-27 10:49           ` lekktu
2010-06-26 21:42     ` Dmitry A. Kazakov
2010-06-26 22:01       ` lekktu
2010-06-27  8:04       ` Gnat GPL 2010 available soon (conditional expressions) Georg Bauhaus
2010-06-27  8:37         ` Dmitry A. Kazakov
2010-06-27 10:55           ` lekktu
2010-06-27 12:12             ` Dmitry A. Kazakov
2010-06-27 13:42               ` Georg Bauhaus
2010-06-27 14:35                 ` Peter C. Chapin
2010-06-27 16:53                   ` Dmitry A. Kazakov
2010-06-28 11:24                     ` Peter C. Chapin
     [not found]                       ` <oizwym2afwmx.1jm5tt7wtpm7v.dlg@40tude.net>
2010-06-28 14:47                         ` Georg Bauhaus
2010-06-28 16:36                           ` Dmitry A. Kazakov
2010-06-28 17:04                             ` Georg Bauhaus
2010-06-28 17:37                               ` Dmitry A. Kazakov
2010-06-29 19:28                   ` Randy Brukardt
2010-06-30  1:19                     ` BrianG
2010-06-30  3:21                       ` Britt Snodgrass
2010-07-05  1:27                         ` Phil Clayton
2010-07-05 10:26                           ` Georg Bauhaus
2010-07-05 14:24                             ` Phil Clayton
2010-07-05 13:12                           ` Dmitry A. Kazakov
2010-07-05 22:47                             ` Phil Clayton
2010-07-06  7:36                               ` Dmitry A. Kazakov
2010-07-06  9:13                                 ` Georg Bauhaus
2010-07-06 16:31                                 ` Phil Clayton [this message]
2010-07-06 17:18                                   ` Dmitry A. Kazakov
2010-07-07 12:00                                     ` Phil Clayton
2010-07-07 13:39                                       ` Dmitry A. Kazakov
2010-06-30  4:13                       ` Gautier write-only
2010-06-30 16:46                         ` Warren
2010-06-30  4:09                     ` Gautier write-only
2010-06-30 23:20                       ` Peter C. Chapin
2010-06-27 21:40 ` Gnat GPL 2010 available soon mahdert
replies disabled

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