comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin@thedowies.com>
Subject: Re: Ada202X : Adding functors
Date: Wed, 14 Nov 2012 10:54:01 -0800 (PST)
Date: 2012-11-14T10:54:01-08:00	[thread overview]
Message-ID: <e2741bb0-f54f-4999-b320-c4340ca84a53@googlegroups.com> (raw)
In-Reply-To: <8373eaf3-5299-4bbb-a462-56d2d76d6333@googlegroups.com>

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:
> 
> > On Wednesday, November 14, 2012 12:51:03 AM UTC, Adam Beneschan wrote:
> 
> > 
> 
> > > On Tuesday, November 13, 2012 3:11:57 AM UTC-8, Martin wrote:
> 
> 
> 
> > It may have been the intent to add only 'array-like' accessors to containers but they've opened up something more...
> 
> 
> 
> 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 tagged type, using aspects that are intended for implicit array referencing or user-defined access dereferencing, applying a parameter list to an object of 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 just adding a normal subprogram name (which I've called Perform in the snippet below) and writing something like:
> 
> 
> 
>    F1 : Algorithm := Double_Then_Power.Create (1.0);
> 
>    F2 : Algorithm := Double_Then_Power.Create (2.0);
> 
>    F3 : Algorithm := F1;  -- Assigning one functor to another...
> 
> begin
> 
>    Put_Line ("F1 := " & Long_Float'Image (F1.Perform(2)));
> 
>    Put_Line ("F2 := " & Long_Float'Image (F2.Perform(3)));
> 
>    Put_Line ("F3 := " & Long_Float'Image (F3.Perform(1)));
> 
> 
> 
> You can already do this in Ada 2005; no need to use the new accessor features, which are confusing because you're trying to use them in a way they're not intended to be used.
> 
> 
> 
> 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", and (2) programmers can already abuse features of the language to make it look 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. 
> 
> 
> 
>                                 -- 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 same 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 offer an opportunity for the compiler to perform better optimisation than it can with a function pointer, which is roughly the alternative. I don't know if that would be true for Ada compilers but if I don't ask by throwing out this idea then I'll never know. In C++, the other main advantage is that templates neither know nor care if they thing they are working with is a function or a functor they both look the same. Ada isn't going to get that advantage - but it's a huge win in the C++ world.

I note people are offering alternatives like using "+" but that's as much an abuse as anything I've done in the above - perhaps people are used to seeing 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 came out...I simply couldn't believe what I was seeing was better than my lovely Ada83 code...but I got used to it and now I look at Ada95 code and think it looks awful compared to how I write Ada2012!

I suspect adding this may only make sense in the context of perhaps expanding the generics model not sure…as I mentioned in another post, if the typing was a little bit Duck-ish wrt generic type parameters.

-- Martin



  reply	other threads:[~2012-11-14 18:54 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-12 22:09 Ada202X : Adding functors Martin
2012-11-12 23:14 ` Jeffrey Carter
2012-11-12 23:19   ` Martin
2012-11-13 10:45     ` Georg Bauhaus
2012-11-13 12:08       ` Yannick Duchêne (Hibou57)
2012-11-13 12:35       ` Martin
2012-11-12 23:44 ` Adam Beneschan
2012-11-13  2:11   ` Jeffrey Carter
2012-11-13 11:11   ` Martin
2012-11-14  0:51     ` Adam Beneschan
2012-11-14  8:39       ` Martin
2012-11-14 16:54         ` Adam Beneschan
2012-11-14 18:54           ` Martin [this message]
2012-11-14 20:37           ` Dmitry A. Kazakov
2012-11-14 20:57             ` Shark8
2012-11-14 21:31             ` Martin
2012-11-14 22:42               ` Adam Beneschan
2012-11-15  9:27               ` Dmitry A. Kazakov
2012-11-14 21:45             ` Simon Wright
2012-11-14 22:22               ` Martin
2012-11-14 22:27               ` Martin
2012-11-13  4:22 ` Shark8
2012-11-15  0:20 ` sbelmont700
2012-11-15  7:12   ` Martin
2012-11-15 12:21     ` Georg Bauhaus
2012-11-15 12:31     ` Georg Bauhaus
2012-11-15 12:46       ` Martin
2012-11-16  6:15       ` Randy Brukardt
2012-11-15 10:11   ` Dmitry A. Kazakov
2012-11-15 15:52     ` Peter C. Chapin
2012-11-15 17:04       ` Dmitry A. Kazakov
2012-11-15 19:57         ` Georg Bauhaus
2012-11-15 20:39           ` Dmitry A. Kazakov
2012-11-16  0:15             ` Peter C. Chapin
2012-11-16 10:12               ` Georg Bauhaus
2012-11-16  0:01         ` Peter C. Chapin
2012-11-16  6:09           ` Randy Brukardt
2012-11-16 12:35             ` Peter C. Chapin
2012-11-16 18:10               ` Martin
2012-11-16  8:59           ` Dmitry A. Kazakov
2012-11-16 12:20             ` Peter C. Chapin
2012-11-16 17:44               ` Dmitry A. Kazakov
2012-11-18 15:58                 ` Peter C. Chapin
2012-11-15 21:34     ` sbelmont700
replies disabled

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