comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada202X : Adding functors
Date: Fri, 16 Nov 2012 18:44:47 +0100
Date: 2012-11-16T18:44:47+01:00	[thread overview]
Message-ID: <1a6o8r3qx00mt.q6xayy8lqwr4$.dlg@40tude.net> (raw)
In-Reply-To: V_ydnYxuOZI2sjvNRVn_vwA@giganews.com

On Fri, 16 Nov 2012 07:20:58 -0500, Peter C. Chapin wrote:

> On 11/16/2012 03:59 AM, Dmitry A. Kazakov wrote:
> 
>>     type T is tagged ...
>>     procedure Operation (X : T);
>>
>> There is only one instance of Operation for T. This is easy when Operation
>> is not an object. Once you make it an object, there could possibly be more
>> than one instance of.
>>
>>     X : T'Class;
>> begin
>>     X.Operation;  -- Which one instance is called here?
> 
> Isn't this an issue even without first class functions? It sounds like 
> you are talking about dynamic dispatch... an OOP issue, not a functional 
> issue. I guess I'm still not following you.

It is about how many instances of primitive

   procedure (X : T)

are allowed to exist. It is different from dispatch which selects instances
of different functional types. E.g.

   procedure (X : T)
   procedure (X : S)

S /= T

>>> def filter(someList: List[Int], predicate: Int => Boolean) = ...
>>>
>>> This defines a function 'filter' that takes a list of integers and a
>>> function from Int to Boolean. The notation 'Int => Boolean' is a
>>> function type. And yes, you can write types like
>>>
>>> 	(Int => Boolean) => String
>>>
>>> for functions taking a (function from Int to Boolean) and returning
>>> String. It's no big deal.
>>
>> Can I inherit it?
> 
> Yes.
> 
> class MyClass extends (Int => Boolean) => String {
>    // ...
> }

And the semantics of? Considering this:

   type T is tagged ...
   procedure Operation (X : T);

   procedure Operation_1 (X : T) is new Operation (X : T) with ...;

would mean what?

>> Override it?
> 
> Not sure what you mean by this.

1. When you inherit from Operation you inherit higher-order functions
defined on Operation (not on T). May I override them?

2. Let I inherited from Operation and overrode Operation in T. What
happens?

3. The class of operations derived from:

   procedure (X : T)
   
is

   procedure (X : T)'Class

What is the semantics of? In which relation is it with

  procedure (X : T'Class)
  procedure (X : T'Class)'Class

>> Which are the classes of types
>>
>>     (Int => Boolean) => String
>>
>> operates on?
> 
> Scala treats function types as classes with a special 'apply' method. 

This is equivalent to Ada's access to subprogram. But I suggest that
"apply" cannot be overridden just like Ada's all cannot. Which flattens the
type structure. The recursion is killed because "apply" or "all" are not
really first-class.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2012-11-16 17:44 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 [this message]
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