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,CP1252 Received: by 10.224.219.144 with SMTP id hu16mr10436422qab.1.1352919242091; Wed, 14 Nov 2012 10:54:02 -0800 (PST) Received: by 10.52.96.71 with SMTP id dq7mr541765vdb.11.1352919242068; Wed, 14 Nov 2012 10:54:02 -0800 (PST) Path: gf5ni57984567qab.0!nntp.google.com!u2no2648000qal.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 14 Nov 2012 10:54:01 -0800 (PST) In-Reply-To: <8373eaf3-5299-4bbb-a462-56d2d76d6333@googlegroups.com> 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada202X : Adding functors From: Martin Injection-Date: Wed, 14 Nov 2012 18:54:02 +0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Date: 2012-11-14T10:54:01-08:00 List-Id: On Wednesday, November 14, 2012 4:54:10 PM UTC, Adam Beneschan wrote: > On Wednesday, November 14, 2012 12:39:07 AM UTC-8, Martin wrote: >=20 > > On Wednesday, November 14, 2012 12:51:03 AM UTC, Adam Beneschan wrote: >=20 > >=20 >=20 > > > On Tuesday, November 13, 2012 3:11:57 AM UTC-8, Martin wrote: >=20 >=20 >=20 > > It may have been the intent to add only 'array-like' accessors to conta= iners but they've opened up something more... >=20 >=20 >=20 > A new way to write obfuscated code? Why do you think this would convince= me or anything else to support a language change? You're declaring a tagg= ed type, using aspects that are intended for implicit array referencing or = user-defined access dereferencing, applying a parameter list to an object o= f the tagged type, and expecting readers to figure out what you mean. And = you *still* haven't given any argument for why this would be better than ju= st adding a normal subprogram name (which I've called Perform in the snippe= t below) and writing something like: >=20 >=20 >=20 > F1 : Algorithm :=3D Double_Then_Power.Create (1.0); >=20 > F2 : Algorithm :=3D Double_Then_Power.Create (2.0); >=20 > F3 : Algorithm :=3D F1; -- Assigning one functor to another... >=20 > begin >=20 > Put_Line ("F1 :=3D " & Long_Float'Image (F1.Perform(2))); >=20 > Put_Line ("F2 :=3D " & Long_Float'Image (F2.Perform(3))); >=20 > Put_Line ("F3 :=3D " & Long_Float'Image (F3.Perform(1))); >=20 >=20 >=20 > You can already do this in Ada 2005; no need to use the new accessor feat= ures, which are confusing because you're trying to use them in a way they'r= e not intended to be used. >=20 >=20 >=20 > You haven't given a good argument for why we need to change the language = so that programmers can write the above without the .Perform. So far, your= only arguments seem to be (1) you can do it in C++ and it's "very cool", a= nd (2) programmers can already abuse features of the language to make it lo= ok the way you want, so we should enshrine it. Sorry, but it would take a = lot more than that to convince me that we would need a language change.=20 >=20 >=20 >=20 > -- Adam Sorry, too busy to write anything else...had to go and work!! Yes, you're right, I have used in ways that perhaps the ARG didn't intend -= I feel quite chuffed I managed to make it do that! It's not quite in the s= ame league as discovering C++ templates supported meta-programming though! = :-) And, yes, this is a very straw-ish strawman. The reasons could be the same as those given for C++. In C++, functors offe= r an opportunity for the compiler to perform better optimisation than it ca= n with a function pointer, which is roughly the alternative. I don't know i= f that would be true for Ada compilers but if I don't ask by throwing out t= his idea then I'll never know. In C++, the other main advantage is that tem= plates neither know nor care if they thing they are working with is a funct= ion or a functor they both look the same. Ada isn't going to get that advan= tage - but it's a huge win in the C++ world. I note people are offering alternatives like using "+" but that's as much a= n abuse as anything I've done in the above - perhaps people are used to see= ing that already. Yes, it is in part just down to 'coolness' but why shouldn't Ada be cool? A= little bit of cool might bring Ada-based companies more business... And any new language syntax is always obfuscatory - I HATED Ada95 when it c= ame out...I simply couldn't believe what I was seeing was better than my lo= vely Ada83 code...but I got used to it and now I look at Ada95 code and thi= nk it looks awful compared to how I write Ada2012! I suspect adding this may only make sense in the context of perhaps expandi= ng the generics model not sure=85as I mentioned in another post, if the typ= ing was a little bit Duck-ish wrt generic type parameters. -- Martin