comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Derived private interface
Date: Wed, 3 Aug 2011 11:01:52 +0200
Date: 2011-08-03T11:01:52+02:00	[thread overview]
Message-ID: <nwyetwf3hqn7$.gm3c388p0s3c$.dlg@40tude.net> (raw)
In-Reply-To: j19pfe$aj0$1@munin.nbi.dk

On Tue, 2 Aug 2011 16:16:27 -0500, Randy Brukardt wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
> news:1nvqqny2226ro$.1ixvoiht8zu8l$.dlg@40tude.net...
>> On Mon, 1 Aug 2011 16:56:17 -0500, Randy Brukardt wrote:
>>
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
>>> news:1rlxo1uthv5xt.1agapd9q0mek4$.dlg@40tude.net...
>>> ...
>>>> BTW, Generic_Dispatching_Constructor of Ada 2005 did not change much to
>>>> Ada
>>>> 95 because of tags. You still need a registering layer to maintain
>>>> external name to tag mapping.
>>>
>>> It did eliminate one thing, the need to have a scheme to create an object 
>>> of
>>> each tagged type. That forced the use of either a case statement or an
>>> access-to-subprogram, either of which is error-prone.
>>
>> I don't consider the case statement because it is just a wrong pattern.
>> Regarding mappings type ID to either a constructing function or tag, they
>> are equivalent. Both require the same amount of maintenance.
> 
> There are more sources of error when using access-to-subprogram; it's easy 
> to forget to create a routine or use the wrong one.

Yes there is some advantage that the function in dispatching constructor is
primitive:

   function Create (...) return T;

For access-to-subprogram it is class-wide:

   function Create (...) return T'Class;

As for using a wrong subprogram you can also register a wrong tag. That is
same.

BTW, the patterns are:

      -- with generic dispatching constructor
   type T is tagged ...;
   function Create (...) return T;
   procedure Register (ID : ID_Type; Construct : Tag);

   --- Usage:

   package P is
      type S is new T with ...;
      overriding function Create (...) return S;
   end P;

   package body P is
      ...
   begin
      Register (S_ID, S'Tag);
   end P;

vs.

      -- Ada 95 access-to-subprogram solution
   type T is tagged ...;
   type Factory is access function Create (...) return T'Class;
   procedure Register (ID : ID_Type; Constructor : Factory);

   -- Usage:

   package P is
      type S is new T with ...;
   end P;

   package body P is
      function Create (...) return T'Class is
         ...
      end Create;
      ...
   begin
      Register (S_ID, Create'Access);
   end P;
   
>>> There is no possibility of eliminating the need for some sort of registry --
>>> although in some cases you can use the one built-into the language (the
>>> External_Tag). There has to be a mapping somewhere of some sort of key to a
>>> tag, since it isn't possible to export tags to the "real world".
>>
>> It is possible, and even required for distributed weakly coupled
>> applications, but in order to do that you have to export the types
>> themselves rather than their tags.
> 
> It might be possible for some non-Ada language, but it's not possible for 
> Ada (and this is an Ada site and I was only talking about Ada here).

Well, if Ada designers are serious about addressing distributed systems
(Annex E), that has to happen. Either a kind of IDL must be put into the
Ada standard (highly undesired) or some other, more reasonable, means must
be provided to populate types. [Of course the type system must be brought
in order before even considering this sort of issues.]

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



  reply	other threads:[~2011-08-03  9:01 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05  3:14 Derived private interface Rego, P.
2011-07-05  5:10 ` AdaMagica
2011-07-06  2:24   ` Rego, P.
2011-07-06  4:34   ` AdaMagica
2011-07-06  7:55     ` Georg Bauhaus
2011-07-06  8:30       ` AdaMagica
2011-07-06 12:59         ` Georg Bauhaus
2011-07-06 13:23           ` AdaMagica
2011-07-06 19:06             ` Randy Brukardt
2011-07-06 13:28           ` Simon Wright
2011-07-06 19:45           ` Randy Brukardt
2011-07-06 22:05             ` Georg Bauhaus
2011-07-06 23:56               ` Adam Beneschan
2011-07-07 14:09                 ` Georg Bauhaus
2011-07-07 15:10                   ` Adam Beneschan
2011-07-08  4:29                     ` AdaMagica
2011-07-08 19:08                       ` Randy Brukardt
2011-07-08 19:12                     ` Randy Brukardt
2011-07-07 15:19                   ` Georg Bauhaus
2011-07-07 10:37         ` Stephen Leake
2011-07-07 13:18           ` Georg Bauhaus
2011-07-08 19:23             ` Randy Brukardt
2011-07-08 21:41               ` Jeffrey Carter
2011-07-09  6:14                 ` Dmitry A. Kazakov
2011-07-22 22:59                 ` Randy Brukardt
2011-07-23  7:30                   ` Jeffrey Carter
2011-07-23  9:29                     ` Maciej Sobczak
2011-07-23 10:07                     ` Dmitry A. Kazakov
2011-07-26 21:04                     ` Randy Brukardt
2011-07-26 23:43                       ` Jeffrey Carter
2011-07-27 23:56                         ` Randy Brukardt
2011-07-28  0:18                           ` Jeffrey Carter
2011-07-28 10:06                         ` Maciej Sobczak
2011-07-28 23:24                           ` Randy Brukardt
2011-07-29  6:45                             ` Simon Wright
2011-07-30  0:04                               ` Randy Brukardt
2011-07-30  6:32                                 ` Simon Wright
2011-08-01  9:30                                   ` Alex R. Mosteo
2011-08-01 10:12                                     ` Dmitry A. Kazakov
2011-08-01 21:56                                       ` Randy Brukardt
2011-08-02 10:03                                         ` Dmitry A. Kazakov
2011-08-02 21:16                                           ` Randy Brukardt
2011-08-03  9:01                                             ` Dmitry A. Kazakov [this message]
2011-08-03 20:16                                               ` Randy Brukardt
2011-08-04  8:15                                                 ` Dmitry A. Kazakov
2011-08-09 21:10                             ` Maciej Sobczak
2011-08-09 21:35                               ` Randy Brukardt
2011-08-10  9:11                                 ` Dmitry A. Kazakov
2011-08-10 21:56                                   ` Randy Brukardt
2011-08-11  8:07                                     ` Dmitry A. Kazakov
2011-08-12  4:52                                       ` Randy Brukardt
2011-08-12  8:54                                         ` Dmitry A. Kazakov
2011-08-10 10:07                                 ` Maciej Sobczak
2011-08-10 11:26                                   ` Georg Bauhaus
2011-08-10 22:27                                     ` Randy Brukardt
2011-08-10 22:21                                   ` Randy Brukardt
2011-08-11 13:50                                     ` Maciej Sobczak
2011-08-12  4:43                                       ` Randy Brukardt
2011-08-12  7:00                                         ` Maciej Sobczak
2011-08-12 21:59                                           ` Randy Brukardt
2011-07-06 15:06       ` Adam Beneschan
2011-07-06 16:36       ` Dmitry A. Kazakov
2011-07-06 19:20       ` Randy Brukardt
replies disabled

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