comp.lang.ada
 help / color / mirror / Atom feed
From: "Peter C. Chapin" <pcc482719@gmail.com>
Subject: Re: Ada202X : Adding functors
Date: Sun, 18 Nov 2012 10:58:43 -0500
Date: 2012-11-18T10:58:43-05:00	[thread overview]
Message-ID: <FKadnX_ZQewumDTNRVn_vwA@giganews.com> (raw)
In-Reply-To: <1a6o8r3qx00mt.q6xayy8lqwr4$.dlg@40tude.net>

On 11/16/2012 12:44 PM, Dmitry A. Kazakov wrote:

>> class MyClass extends (Int => Boolean) => String {
>>     // ...
>> }
>
> And the semantics of?

In Scala, anyway, there is a "magic" method apply that is used to define 
what happens when an object is applied to arguments. Since function 
types are abstract in Scala the compiler will require the programmer to 
override apply() to define what MyClass objects do when they are used as 
functions.

 > Considering this:
>
>     type T is tagged ...
>     procedure Operation (X : T);
>
>     procedure Operation_1 (X : T) is new Operation (X : T) with ...;
>
> would mean what?

I'm not sure. Are you trying to define a new type similar to

	type My_Integer is new Integer;

Or are you talking about dynamically creating function objects? On the 
other hand based on your comments it sounds like you might be talking 
about adding "methods" to existing "classes" (using non-Ada 
terminology). Or maybe you are speculating about the behavior of 
function types if they were also tagged types themselves. I can't tell 
from your presentation what you are talking about.

Anyway, it could well be the case that adding first class functions to 
Ada would be a bad idea due to unfavorable interactions with existing 
features. Perhaps this is what your examples are illustrating. But... 
that doesn't mean that first class functions are "weakly typed" in 
general. I believe that was your original assertion and that's what I'm 
taking exception to.

It might be interesting to note that, again in Scala at least, methods 
and functions are treated differently and methods are not really first 
class (although functions are). The compiler will implicitly wrap a 
method in a closure so it can be treated like a function but doing so 
needs a specific object to resolve the method's internal 'this' 
reference. If one wanted to get serious about adding first class 
functions to Ada perhaps a similar path could be followed to make it 
work sensibly.

Peter




  reply	other threads:[~2012-11-18 15:58 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
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 [this message]
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