From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,334f9012742e58fc X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!y11g2000yqm.googlegroups.com!not-for-mail From: Phil Clayton Newsgroups: comp.lang.ada Subject: Re: Gnat GPL 2010 available soon (conditional expressions) Date: Tue, 6 Jul 2010 09:31:05 -0700 (PDT) Organization: http://groups.google.com Message-ID: <87dfe70c-fd5b-4b76-8e37-b38539826502@y11g2000yqm.googlegroups.com> References: <2010061621145016807-sjs@essexacuk> <0fa4c574-9539-492f-8514-d32c68beb22a@w31g2000yqb.googlegroups.com> <1frrgtpa5dycl$.12kl72iqsg3dx$.dlg@40tude.net> <4c270613$0$6974$9b4e6d93@newsspool4.arcor-online.net> <1wuwvzgwlwgli$.1birkinieia0d$.dlg@40tude.net> <1ur19ais2ejih.mjbgdsv9pr66.dlg@40tude.net> <4c275562$0$6987$9b4e6d93@newsspool4.arcor-online.net> <4c276114$0$2378$4d3efbfe@news.sover.net> <7ec98a71-edcb-4851-87fd-6702fb963829@q12g2000yqj.googlegroups.com> <8ac6b8d6-f4c0-4a8b-b3aa-ff6f2d136544@k39g2000yqb.googlegroups.com> <1wl74eppoqii9$.1oxpbe851z3jk$.dlg@40tude.net> NNTP-Posting-Host: 91.110.187.202 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1278433865 22049 127.0.0.1 (6 Jul 2010 16:31:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 6 Jul 2010 16:31:05 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y11g2000yqm.googlegroups.com; posting-host=91.110.187.202; posting-account=v7gx3AoAAABfjb9m5b7l_Lt2KVEgQBIe User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.15) Gecko/2009102704 Fedora/3.0.15-1.fc10 Firefox/3.0.15,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12227 Date: 2010-07-06T09:31:05-07:00 List-Id: On Jul 6, 8:36=A0am, "Dmitry A. Kazakov" wrote: > On Mon, 5 Jul 2010 15:47:41 -0700 (PDT), Phil Clayton wrote: > > On Jul 5, 2:12=A0pm, "Dmitry A. Kazakov" > > 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 > > >>> =A0 (for I in 1 .. 5 =3D> (for J in 1 .. 7 =3D> (if I =3D J then 1.0 = else > >>> 0.0))) > > >> =A0 (for I in 1..5 =3D> (for J in 1..7 =3D> Float (Boolean'Pos (I =3D = 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 na= me > the components of an array element index. Definitely the latter... > In the latter case > > =A0 =A0(I, J : others =3D> ) > =A0 =A0(I : 1..5 =3D> ) > =A0 =A0(Odd : 1 | 3 | 5 | 7 =3D> , others = =3D> 0.0) > =A0 =A0etc > > looks to me more consistent with existing Ada, e.g. when Error : others = =3D> > 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 =3D> 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 =3D> 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 =3D> ...) surely I and J would always be equal: there are only 5 elements in the array. Having (for I in 1 .. 5 =3D> ...) syntactically rules out multiple variables. Phil