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,2078ce7aac45af5b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.207.66 with SMTP id fx2mr9096261qab.7.1352854263116; Tue, 13 Nov 2012 16:51:03 -0800 (PST) Received: by 10.52.91.168 with SMTP id cf8mr9754vdb.6.1352854263093; Tue, 13 Nov 2012 16:51:03 -0800 (PST) Path: gf5ni56274882qab.0!nntp.google.com!u2no635484qal.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 13 Nov 2012 16:51:03 -0800 (PST) In-Reply-To: <57bca956-2348-4825-8f5f-04fb91863696@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <0114d327-9f9f-4ad2-9281-56331d11a90c@googlegroups.com> <2bb9e5fa-04a2-4073-bca1-1739ce0580f1@googlegroups.com> <57bca956-2348-4825-8f5f-04fb91863696@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <094f94ed-dbcc-4dba-bd9d-894a75f69037@googlegroups.com> Subject: Re: Ada202X : Adding functors From: Adam Beneschan Injection-Date: Wed, 14 Nov 2012 00:51:03 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-11-13T16:51:03-08:00 List-Id: On Tuesday, November 13, 2012 3:11:57 AM UTC-8, Martin wrote: >=20 > But Adam - that's cool cat is already out the bag! Well, that's a compelling reason to add a major new language feature. Not. > E.g. > =20 > with Ada.Text_IO; use Ada.Text_IO; > with Project; use Project; > with Matrix_3x3s; use Matrix_3x3s; > with Vector_3s; use Vector_3s; > procedure Test is > procedure Display (X : Real) is > begin > Put_Line (Real'Image (X)); > end Display; > V : Vector_3 :=3D Create (X =3D> 12.34, > Y =3D> 123.4, > Z =3D> 1234.0); > M : Matrix_3x3 :=3D (Create (X =3D> V, > Y =3D> V * 2.0, > Z =3D> V * 4.0)); > begin > V (1) :=3D 1.0; > Display (V (1)); > Display (V (2)); > Display (V (3)); > M (1, 1) :=3D 20.0; > Display (M (1, 1)); > end Test; >=20 > V and M used as-if they were functions Umm, no, since you can't have a function call (by itself) on the left side = of an assignment. They're being used as arrays, not as functions. And I t= hink that's probably one of the reasons Constant_Indexing and Variable_Inde= xing were added; there wasn't any good way to declare an object that wasn't= actually an array but that you wanted to be able to use like an array, whe= re you could define an indexing operation that would produce a *variable* t= hat could be used on the left side of an assignment (or in other situations= where a variable was required). Also, I think it was related to some new = features allowing iteration over a container. I'm really not clear on the = details of why this feature was added--I'm mostly just guessing--but the AI= involved does mention a desire to avoid syntactic awkwardness and a lot of= extra text. And I don't see anything in your example (the one in your ori= ginal post) where there's any awkwardness that needs to be avoided. The wo= rkaround I posted involves just adding one more identifier, and in my opini= on adding this would make things clearer to the reader, while the syntax yo= u're proposing is, I think, likely to make things more confusing. There may be other, more complex cases, though, where this would be a usefu= l feature. I haven't yet followed the link Georg posted, but I'm going to;= maybe there are some examples there that would make it clearer why a featu= re would be worthwhile in Ada. So far I haven't seen anything like that in= the examples here. -- Adam