comp.lang.ada
 help / color / mirror / Atom feed
From: "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de>
Subject: Re: Using Red-Black Trees
Date: Thu, 18 Nov 2010 01:13:46 +0100
Date: 2010-11-18T01:13:46+01:00	[thread overview]
Message-ID: <op.vmcaw8s3lzeukk@jellix.jlfencey.com> (raw)
In-Reply-To: op.vmb9btjnule2fv@garhos

Yannick Duchêne (Hibou57) wrote:

> Le Thu, 18 Nov 2010 00:15:11 +0100, Vinzent Hoefler
> <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> a écrit:
>>
>> There are still separates. Of course, it's a compile time decision and it
>> would be part of the build system, not the language itself.
> You can have only one at a time. If you select an implementation, you
> select it system-wide, and you cannot select one for that usage and
> another for another usage in the same system.

Sure. I wouldn't propose it as a perfect solution. But we use that feature
quite often to provide different implementations depending on the target.
So it doesn't seem totally useless in the given context.

> The problem is that this is a lack of orthogonality, which is surprisingly
> an Ada famous feature (Ada forget this one). This is the same issue as the
> one you get with language with which classes is the only way to achieve
> encapsulation. With these, you end to use classes when you do not need it
> at the first place and indeed needed package instead. Here, I would like
> to be able to do something which has nothing at all to deal with
> polymorphism, and I cannot do it without polymorphism because Ada do not
> provide orthogonality here.

Well, isn't providing different implementations with a common interface
equivalent to "polymorphism"? I mean, if you don't look at the implementation
how can you tell the difference? ;)

For instance, instead of using an abstract tagged type and dispatching you
could also use "delegation" (I hope that's the right term) to different
implementations under a common interface without reverting to tagged types.
I still would consider that polymorphism (actually, we do that with the
communication subsystem, the implementation decides at run-time which sort of
communication is the most efficient, depending on the physical location
of sender and receiver).

> implementation. In less words, would like Ada package specification to be
> more abstract; just like you can have multiple entities, all instance of a
> type, would be nice to be able to have multiple implementations, all
> instance of a specification.

You mean like - let me quickly think of a syntax ... - non-Ada, of course -

-- 8< spec --
package Foo
    --  Some notion to hint the compiler there may be different bodies.
    select Implementation_Choice is (Binary_Tree, Linked_List);
is
    type Bar is ...;

    procedure Implementation_Specific (X : Bar) with Implementation_Choice;
    procedure Common (X : Bar);

end Foo;
-- 8< --

-- 8< body --
package body Foo is

    procedure Foobar (X : Bar)
       case Implementation_Choice

          when Binary_Tree =>
             is
                ...
             begin
                ... binary tree.
             end Foobar (Binary_Tree);

         when Linked_List =>
             is
                ...
             begin
                ... linked list.
             end Foobar (Linked_List);
      end case;
   end Foobar;
end Foo;
-- 8< --

-- 8< usage --
with Foo; for Foo.Implementation_Choice use Foo.Binary_Tree;
-- 8< --


Vinzent.

-- 
Mail address temporary, use domain to filter.



  reply	other threads:[~2010-11-18  0:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-13 11:20 Using Red-Black Trees Björn
2010-11-13 12:14 ` Phil Thornley
2010-11-13 13:10 ` Alex Mentis
2010-11-13 13:23   ` Björn
2010-11-13 13:53     ` Alex Mentis
2010-11-13 14:06       ` Björn
2010-11-13 16:31       ` Simon Wright
2010-11-15  8:49   ` Stephane Carrez
2010-11-15 15:32     ` John B. Matthews
2010-11-15 22:46   ` Randy Brukardt
2010-11-16 16:10     ` Gene
2010-11-16 17:17       ` Alex Mentis
2010-11-16 19:51         ` Randy Brukardt
2010-11-16 21:24           ` Colin Paul Gloster
2010-11-17  2:50           ` Alex Mentis
2010-11-17  5:10             ` Adam Beneschan
2010-11-17 22:59               ` Yannick Duchêne (Hibou57)
2010-11-17 23:15                 ` Vinzent Hoefler
2010-11-17 23:39                   ` Yannick Duchêne (Hibou57)
2010-11-18  0:13                     ` Vinzent Hoefler [this message]
2010-11-18  6:27                     ` J-P. Rosen
2010-11-18  7:08                       ` Yannick Duchêne (Hibou57)
2010-11-18 10:47                         ` stefan-lucks
2010-11-18 10:45                           ` Yannick Duchêne (Hibou57)
2010-11-18  9:02                       ` Dmitry A. Kazakov
2010-11-18 12:36                         ` J-P. Rosen
2010-11-18 13:23                           ` Dmitry A. Kazakov
2010-11-17 22:38     ` Yannick Duchêne (Hibou57)
2010-11-13 21:53 ` Jeffrey Carter
2010-11-14  8:20   ` Björn
2010-11-14  8:37     ` Dmitry A. Kazakov
2010-11-13 23:51 ` robin
replies disabled

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