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.180.141 with SMTP id bu13mr10851951qab.2.1352931769259; Wed, 14 Nov 2012 14:22:49 -0800 (PST) Received: by 10.49.76.65 with SMTP id i1mr11113qew.24.1352931768235; Wed, 14 Nov 2012 14:22:48 -0800 (PST) Path: gf5ni57984567qab.0!nntp.google.com!u2no3066108qal.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 14 Nov 2012 14:22:48 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=92.235.245.78; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G NNTP-Posting-Host: 92.235.245.78 References: <0114d327-9f9f-4ad2-9281-56331d11a90c@googlegroups.com> <2bb9e5fa-04a2-4073-bca1-1739ce0580f1@googlegroups.com> <57bca956-2348-4825-8f5f-04fb91863696@googlegroups.com> <094f94ed-dbcc-4dba-bd9d-894a75f69037@googlegroups.com> <8373eaf3-5299-4bbb-a462-56d2d76d6333@googlegroups.com> <1na6brajyyab1.1m57ova8gzvwk$.dlg@40tude.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada202X : Adding functors From: Martin Injection-Date: Wed, 14 Nov 2012 22:22:49 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-11-14T14:22:48-08:00 List-Id: On Wednesday, November 14, 2012 9:45:26 PM UTC, Simon Wright wrote: > "Dmitry A. Kazakov" writes: >=20 >=20 >=20 > > On Wed, 14 Nov 2012 08:54:09 -0800 (PST), Adam Beneschan wrote: >=20 > > >=20 > >> A new way to write obfuscated code? >=20 > > >=20 > > I don't understand the point. If there is any obfuscation then on the >=20 > > Ada's side which does not support straightforward declaration of >=20 > > user-defined arrays/indexing operation. >=20 >=20 >=20 > This is Martin's code: >=20 >=20 >=20 > procedure Test is >=20 > F1 : constant Algorithm :=3D C_To_F.Create (10.0); >=20 > F2 : constant Algorithm :=3D C_To_F.Create (20.0); >=20 > begin >=20 > Put_Line ("F1 :=3D " & Long_Float'Image (F1(X))); >=20 > Put_Line ("F2 :=3D " & Long_Float'Image (F2(X))); >=20 > end Test; >=20 >=20 >=20 > F1(X) is a user-defined array indexing which returns the Fahrenheit >=20 > equivalent of the 10.0 Celsius that F1 was created with *no matter what >=20 > index you supply* because the only purpose of making it look like an >=20 > array indexing was to avoid making it look like what it is - a >=20 > subprogram call. >=20 >=20 >=20 > There may be some point in this in C++, if the templating mechanism only >=20 > cares about the syntactic feature of ()-represents-invocation. I'm not >=20 > sure I want to know. Simon, remember that 'X' is there to make this work at all with Ada2012...h= ence my asking 'what about Ada202X'. And, yes, it may only be of real worth= if Ada generic change too (see my other thought on that...I thinking about= calling that proposal 'Swan typing'...a bit like Duck typing but stronger = and more elegant ;-) I'm actually amazed I'm managed to implement any sort of functors at all in= Ada2012 :-) -- Martin