comp.lang.ada
 help / color / mirror / Atom feed
* Re: Signature Package With Generic Proceedure
       [not found] <045f7b44-2a4a-4292-80fd-0b6bc8ee3465@googlegroups.com>
@ 2012-07-21 22:22 ` Adam Beneschan
  2012-07-22  7:28   ` Dmitry A. Kazakov
  2012-07-22 16:22   ` Keean Schupke
  2012-07-23 10:26 ` Simon Wright
  1 sibling, 2 replies; 12+ messages in thread
From: Adam Beneschan @ 2012-07-21 22:22 UTC (permalink / raw)


On Saturday, July 21, 2012 10:22:25 AM UTC-7, Keean Schupke wrote:
> If I have a package which defines a procedure like:
> 
> 
> generic
>     with procedure Process(Set : in out Set_Type);
> procedure Update(Set : in out Set_Type);
> 
> 
> How do a declare a Signature package that includes this?
> 
> 
> generic
>     with generic
>         with procedure Process(Set : in out Set_Type);
>     procedure Update(Set : in out Set_Type);
> package Set_Signature is end;
> 
> 
> Is not allowed. Is there some way to do this with nested packages?

There's no such thing as "with generic" in Ada.  That is, there is no way to set things up so that you can instantiate a generic like this:

   package An_Instantiation is new A_Generic (G1);

where G1 is the name of a *generic* subprogram or package.  Nor can I think of a reason why you'd want to.  Perhaps if you gave us an example of what you're trying to accomplish?

                              -- Adam



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
  2012-07-21 22:22 ` Signature Package With Generic Proceedure Adam Beneschan
@ 2012-07-22  7:28   ` Dmitry A. Kazakov
  2012-07-22 16:22   ` Keean Schupke
  1 sibling, 0 replies; 12+ messages in thread
From: Dmitry A. Kazakov @ 2012-07-22  7:28 UTC (permalink / raw)


On Sat, 21 Jul 2012 15:22:36 -0700 (PDT), Adam Beneschan wrote:

> On Saturday, July 21, 2012 10:22:25 AM UTC-7, Keean Schupke wrote:
>> If I have a package which defines a procedure like:
>> 
>> generic
>>     with procedure Process(Set : in out Set_Type);
>> procedure Update(Set : in out Set_Type);
>> 
>> How do a declare a Signature package that includes this?
>> 
>> generic
>>     with generic
>>         with procedure Process(Set : in out Set_Type);
>>     procedure Update(Set : in out Set_Type);
>> package Set_Signature is end;
>> 
>> Is not allowed. Is there some way to do this with nested packages?
> 
> There's no such thing as "with generic" in Ada. That is, there is no way
> to set things up so that you can instantiate a generic like this:
> 
>    package An_Instantiation is new A_Generic (G1);
> 
> where G1 is the name of a *generic* subprogram or package. Nor can I
> think of a reason why you'd want to.  Perhaps if you gave us an example of
> what you're trying to accomplish?

Probably it is passing an instance of a specific generic procedure to a
generic package?

Note, rather than passing any procedure with matching signature, e.g.

generic
   with procedure Foo (...);
package Boo ...

, only such Foo, which is an instance of a generic procedure Baz. Imaginary
syntax borrowed from packages:

generic
   with procedure Foo is new Baz (<>); -- This is not Ada!
package Boo ...

This is impossible. An obvious solution is to place Baz into a generic
package and pass an instance of that package instead.

(Ada's generics lack many formal types, e.g. this one)

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



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
  2012-07-21 22:22 ` Signature Package With Generic Proceedure Adam Beneschan
  2012-07-22  7:28   ` Dmitry A. Kazakov
@ 2012-07-22 16:22   ` Keean Schupke
  2012-07-23  0:45     ` Adam Beneschan
  1 sibling, 1 reply; 12+ messages in thread
From: Keean Schupke @ 2012-07-22 16:22 UTC (permalink / raw)


On Saturday, 21 July 2012 23:22:36 UTC+1, Adam Beneschan  wrote:
> On Saturday, July 21, 2012 10:22:25 AM UTC-7, Keean Schupke wrote:
> &gt; If I have a package which defines a procedure like:
> &gt; 
> &gt; 
> &gt; generic
> &gt;     with procedure Process(Set : in out Set_Type);
> &gt; procedure Update(Set : in out Set_Type);
> &gt; 
> &gt; 
> &gt; How do a declare a Signature package that includes this?
> &gt; 
> &gt; 
> &gt; generic
> &gt;     with generic
> &gt;         with procedure Process(Set : in out Set_Type);
> &gt;     procedure Update(Set : in out Set_Type);
> &gt; package Set_Signature is end;
> &gt; 
> &gt; 
> &gt; Is not allowed. Is there some way to do this with nested packages?
> 
> There&#39;s no such thing as &quot;with generic&quot; in Ada.  That is, there is no way to set things up so that you can instantiate a generic like this:
> 
>    package An_Instantiation is new A_Generic (G1);
> 
> where G1 is the name of a *generic* subprogram or package.  Nor can I think of a reason why you&#39;d want to.  Perhaps if you gave us an example of what you&#39;re trying to accomplish?
> 
>                               -- Adam


Why would you want to? Easy... You use signature packages to decouple the implementation from the interface, so that other packages can decide which implementation to use.

Lets say we have two disjoint-set implementations, an Eager_Disjointset and a WUQPC_Disjointset. Both of these share a common interface, which we want to enforce so we declare a separate signature package Disjointset_Signature to describe this common interface.

The algorithms that use Disjointset are written using 


generic
    with package Disjointset is new Disjointset_Signature (<>);
package X is begin


So they can be compiled only 'with' the Disjointset_Signature package.


The final code which uses the algorithm can choose which container implementation to use by:

    package My_Disjointset is new Eager_Disjointset;
    use My_Disjointset;
    package My_Disjointset_Spec is new Disjointset_Signature(
        Set_Type => My_Disjointset.Set_Type
    );
    procedure My_Algorithm is new Algorithm(
        Disjointset_Spec => My_Disjointset_Spec
    );

But another part of the code could use the same algorithm with a different implementation of the container.


The problem comes implementing a function to mutate (update in place) data stored in the container. Maybe we want to implement:

procedure Update(
    Set : in out Set_Type;
    Index : in Index_Type;
    Process : access procedure(
        Element : in out Element_Type
    )
);

But this is slow because the procedure has to be passed as an access and cannot be inlined. So instead we try:

generic
    with procedure Process(
        Element : in out Element_Type;
    );
procedure Update(
    Set : in out Set_Type;
    Index : in Set_Index
);

This is good because 'Process' can be inlined, however how do we express this in the Signature package that represents the interface to these packages?


In the code that uses this we want to instantiate the generic with the relevant Process procedure, without referencing which implementation of Disjointset will eventually be used.

procedure Algorithm(Set : in out Set_Type) is
    procedure My_Process(Element : in out Element_Type) (
        ...
    );
    My_Update is new Update(Process => My_Process);
begin
    for J of Set loop
        My_Update(Set, J);
    end loop;
end Algorithm;


Cheers,
Keean.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
  2012-07-22 16:22   ` Keean Schupke
@ 2012-07-23  0:45     ` Adam Beneschan
       [not found]       ` <79925d0c-b2dd-44a3-9451-48f0ee19485f@googlegroups.com>
  0 siblings, 1 reply; 12+ messages in thread
From: Adam Beneschan @ 2012-07-23  0:45 UTC (permalink / raw)


On Sunday, July 22, 2012 9:22:55 AM UTC-7, Keean Schupke wrote:
> 
> Why would you want to? Easy... You use signature packages to decouple the 
> implementation from the interface, so that other packages can decide which
> implementation to use.

Well, "signatures" are hardly the only way to decouple things, and in practice, of all the possible methods there are to decouple implementations from interfaces, signature packages are probably the last method I would choose.  Do you come from some other language background where the "signature" concept is more common?  Whatever language that is, it sounds like the concept isn't as integral to Ada as it is in your other language.  Because of that, it took me a pretty long time to figure out what you were trying to accomplish.

In fact, in the examples you provide, signatures seem completely unnecessary and confusing.  You appear to have defined a package Disjointset_Signature whose only generic formal is one type.  Presumably, you then define generic packages with formals like

   generic
       with package The_Signature is new Disjointset_Signature;
   procedure Algorithm (Set : in out The_Signature.Set_Type);

But to me, this is a lot more confusing than just declaring

   generic
       type Set_Type is private;
   procedure Algorithm (Set : in out Set_Type);

Generic signatures may have their uses, but I don't think they're all that common in the Ada world.

OK, with that rant out of the way: I think I finally figured out what you were trying to do.  You're trying to declare a generic procedure GP that is parameterized with code from some other procedure P specified by the user, but where P itself needs to be parameterized with another piece of code internal to GP.  And you'd like to do this in a way that allows everything to be done inline, so that a compiler that performs macro-expansion when instantiating  generics (not all do) can generate a procedure Update that includes both code from P and code supplied by GP.

That's an interesting concept, but it isn't supported by Ada, and I can't think of a way to do it.  Furthermore, since what you want can easily be accomplished (but not as efficiently) by access-to-procedures, I'm not sure that it's a good candidate for a new language feature.  Sorry.  You're probably better off asking your compiler vendor for some implementation-defined pragmas to help with this (e.g. if the compiler knows, because of a pragma, that Update will only be called with the 'Access of one known procedure, then the compiler could generate code that doesn't have to use indirect subprogram calls and could inline the known procedure).

                           -- Adam



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
       [not found] <045f7b44-2a4a-4292-80fd-0b6bc8ee3465@googlegroups.com>
  2012-07-21 22:22 ` Signature Package With Generic Proceedure Adam Beneschan
@ 2012-07-23 10:26 ` Simon Wright
  2012-07-23 18:36   ` Keean Schupke
  1 sibling, 1 reply; 12+ messages in thread
From: Simon Wright @ 2012-07-23 10:26 UTC (permalink / raw)


Keean Schupke <keean.schupke@googlemail.com> writes:

> If I have a package which defines a procedure like:
>
>
> generic
>     with procedure Process(Set : in out Set_Type);
> procedure Update(Set : in out Set_Type);
>
>
> How do a declare a Signature package that includes this?
>
>
> generic
>     with generic
>         with procedure Process(Set : in out Set_Type);
>     procedure Update(Set : in out Set_Type);
> package Set_Signature is end;
>
>
> Is not allowed. Is there some way to do this with nested packages?

I guess you meant to say

   generic
       type Set_Type is limited private;
       ...
       with generic
           with procedure Process(Set : in out Set_Type);
       procedure Update(Set : in out Set_Type);
       ...
   package Set_Signature is end;

? in which case I don't see why you couldn't say

   generic
       type Set_Type is limited private;
       ...
       with procedure Update(Set : in out Set_Type);
       ...
   package Set_Signature is end;

Seems to me that all you need is for the actual Update to have that
profile, who cares how it got that way?

I've probably misunderstood this. Could maybe child units help?

   generic
      with procedure Process (Set : in out Set_Type);
   procedure Set_Signature.Update (Set : in out Set_Type);



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
       [not found]         ` <500d3a9d$0$6566$9b4e6d93@newsspool4.arcor-online.net>
@ 2012-07-23 18:29           ` Keean Schupke
  0 siblings, 0 replies; 12+ messages in thread
From: Keean Schupke @ 2012-07-23 18:29 UTC (permalink / raw)


On Monday, 23 July 2012 12:50:52 UTC+1, Georg Bauhaus  wrote:
> On 23.07.12 09:30, Keean Schupke wrote:
> &gt; Object oriented techniques all have considerable runtime costs due to using tagged types, and virtual functions (no inlining).
> 
> Nitpick: O-O in Ada would not necessarily preclude inlining,
> since, by default, finding the primitive subprogram is
> dynamic IFF there is dispatching (when &#39;Class is involved).
> 
> GNAT inlines OO.a and OO.b in clients of the following package
> when the object of type T is specific:
> 
> package OO is
>   type T is tagged record
>     x : Natural;
>   end record;
> 
>   function a (Object : T) return Natural;
>   function b (Object : T; off : Natural) return Natural;
>   pragma inline (a, b);
> end OO;
> 
> package body OO is
>   function a (Object : T) return Natural is (Object.x);
>   function b (Object : T; off : Natural) return Natural is
>   begin
>      return natural&#39;max (1000, Object.x + off);
>   end;
> end OO;

In the example you give surely the record does not need to be tagged at all, in which case this is really just functions and types, no OO at all (and would have been possible in Ada83?). Get rid of the tag, and then parameterise on the type of the object using generics... you can now reuse the same code with different types of Objects.

There is more to it than my bad descriptions. Look at type-classes in Haskell, google "datatype generic programming", and read Stepanov's "Elements of Programming".

Cheers,
Keean.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
  2012-07-23 10:26 ` Simon Wright
@ 2012-07-23 18:36   ` Keean Schupke
  0 siblings, 0 replies; 12+ messages in thread
From: Keean Schupke @ 2012-07-23 18:36 UTC (permalink / raw)


On Monday, 23 July 2012 11:26:03 UTC+1, Simon Wright  wrote:
> Keean Schupke writes:
> 
> &gt; If I have a package which defines a procedure like:
> &gt;
> &gt;
> &gt; generic
> &gt;     with procedure Process(Set : in out Set_Type);
> &gt; procedure Update(Set : in out Set_Type);
> &gt;
> &gt;
> &gt; How do a declare a Signature package that includes this?
> &gt;
> &gt;
> &gt; generic
> &gt;     with generic
> &gt;         with procedure Process(Set : in out Set_Type);
> &gt;     procedure Update(Set : in out Set_Type);
> &gt; package Set_Signature is end;
> &gt;
> &gt;
> &gt; Is not allowed. Is there some way to do this with nested packages?
> 
> I guess you meant to say
> 
>    generic
>        type Set_Type is limited private;
>        ...
>        with generic
>            with procedure Process(Set : in out Set_Type);
>        procedure Update(Set : in out Set_Type);
>        ...
>    package Set_Signature is end;
> 
> ? in which case I don&#39;t see why you couldn&#39;t say
> 
>    generic
>        type Set_Type is limited private;
>        ...
>        with procedure Update(Set : in out Set_Type);
>        ...
>    package Set_Signature is end;
> 
> Seems to me that all you need is for the actual Update to have that
> profile, who cares how it got that way?
> 
> I&#39;ve probably misunderstood this. Could maybe child units help?
> 
>    generic
>       with procedure Process (Set : in out Set_Type);
>    procedure Set_Signature.Update (Set : in out Set_Type);

The Signature package defines the interface, so if the procedure in the signature is not generic, you could not instantiate it with the 'process' procedure you want to use.

Basically a signature package is like the first part of a package that has no body, and you bind it to another package later that actually provides the body.


Cheers,
Keean.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
       [not found]         ` <ac8bfaed-dbcc-491a-a760-c25672445eef@googlegroups.com>
@ 2012-07-23 19:41           ` Keean Schupke
  0 siblings, 0 replies; 12+ messages in thread
From: Keean Schupke @ 2012-07-23 19:41 UTC (permalink / raw)


On Monday, 23 July 2012 10:18:11 UTC+1, Martin  wrote:
> On Monday, July 23, 2012 8:30:15 AM UTC+1, Keean Schupke wrote:
> &gt; Interestingly the only reason for needing the generic procedure in a signature
> &gt; type is to avoid returning access types from the container to allow update-
> &gt; in-place. Am I trying to hard to conform to the &amp;#39;avoid access types&amp;#39;
> &gt; rule for Ada?
> 
> 
> Have you tried using the new Ada2012 aspects &quot;Variable_Indexing&quot;, &quot;Constant_Indexing&quot; and &quot;Implicit_Derefence&quot;?
> 
> -- Martin

These all require a tagged type, which I would rather avoid.


Cheers,
Keean.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
       [not found]       ` <79925d0c-b2dd-44a3-9451-48f0ee19485f@googlegroups.com>
       [not found]         ` <500d3a9d$0$6566$9b4e6d93@newsspool4.arcor-online.net>
       [not found]         ` <ac8bfaed-dbcc-491a-a760-c25672445eef@googlegroups.com>
@ 2012-07-24  2:57         ` Randy Brukardt
       [not found]         ` <jul2n4$af5$1@munin.nbi.dk>
  3 siblings, 0 replies; 12+ messages in thread
From: Randy Brukardt @ 2012-07-24  2:57 UTC (permalink / raw)


"Keean Schupke" <keean.schupke@googlemail.com> wrote in message 
news:79925d0c-b2dd-44a3-9451-48f0ee19485f@googlegroups.com...
...
> This is datatype generic programming, one of the things I thought Ada is 
> good at.
> Signatures are the only way in Ada of doing this with no runtime cost, and 
> the only
> way using generics. Signatures belong to a family of constructs across 
> several languages
> with similar properties. For example:

One more caution: you can't instantiate an Ada generic with a private type, 
unless the formal type is incomplete and there are no objects for the formal 
type.

There are people that want to use signatures in Ada, but it doesn't work 
very well in Ada 2005 and before if you want good encapulation. And it only 
works well in Ada 2012 if you can use a formal incomplete type (usually you 
can if the actual package is empty, which is usually want you want for a 
signature package).

                                          Randy.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
       [not found]         ` <jul2n4$af5$1@munin.nbi.dk>
@ 2012-07-24  8:02           ` Keean Schupke
  2012-07-24  8:43             ` Dmitry A. Kazakov
  0 siblings, 1 reply; 12+ messages in thread
From: Keean Schupke @ 2012-07-24  8:02 UTC (permalink / raw)


On Tuesday, 24 July 2012 03:53:20 UTC+1, Randy Brukardt  wrote:
> &quot;Keean Schupke&quot; wrote in message 
> ...
> &gt; This is datatype generic programming, one of the things I thought Ada is 
> &gt; good at.
> &gt; Signatures are the only way in Ada of doing this with no runtime cost, and 
> &gt; the only way
> &gt; using generics. Signatures belong to a family of constructs across several 
> &gt; languages with
> &gt; similar properties. For example:
> 
> There&#39;s nothing in Ada that says generics have to be implemented with &quot;no 
> runtime cost&quot;. Many Ada 83 implementations, and a few more recent 
> implementations, share all generic instantiations. The effect is very 
> similar to tagged type dispatching, and it&#39;s most useful when there are a 
> lot of instances in a program. Janus/Ada certainly does this (it might be 
> the last to do &quot;universal generic sharing&quot;). Some Ada implementations do 
> &quot;partial generic sharing&quot;, where the parameters involved determine if 
> sharing is used.
> 
> Normally, at this point, I&#39;d say something about premature optimization, but 
> I realize from your past messages that you&#39;re already beyond that stage, so 
> I won&#39;t say any more.
> 
>                                        Randy.

Using DG is a choice like using OO. Languages seem to be very keen to add features to support OO programming. The zero run time cost is 'potential' because all types can be statically determined at compile time. GNAT does this (maybe because it shares a backend with C++)

DG is my programming style of choice at the moment, so some of this is about exploring different languages support for it. At some point C++ has probably overtaken Ada in this regard. Haskell is great but performance is not always good.

At the moment the code written in Ada using Signatures and access variables is faster than C++ (by a couple of percent) when both compiled with GCC.


Cheers,
Keean.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
  2012-07-24  8:02           ` Keean Schupke
@ 2012-07-24  8:43             ` Dmitry A. Kazakov
  2012-07-24  8:59               ` Keean Schupke
  0 siblings, 1 reply; 12+ messages in thread
From: Dmitry A. Kazakov @ 2012-07-24  8:43 UTC (permalink / raw)


On Tue, 24 Jul 2012 01:02:55 -0700 (PDT), Keean Schupke wrote:

> On Tuesday, 24 July 2012 03:53:20 UTC+1, Randy Brukardt  wrote:
>> &quot;Keean Schupke&quot; wrote in message 
>> ...
>> &gt; This is datatype generic programming, one of the things I thought Ada is 
>> &gt; good at.
>> &gt; Signatures are the only way in Ada of doing this with no runtime cost, and 
>> &gt; the only way
>> &gt; using generics. Signatures belong to a family of constructs across several 
>> &gt; languages with
>> &gt; similar properties. For example:
>> 
>> There&#39;s nothing in Ada that says generics have to be implemented with &quot;no 
>> runtime cost&quot;. Many Ada 83 implementations, and a few more recent 
>> implementations, share all generic instantiations. The effect is very 
>> similar to tagged type dispatching, and it&#39;s most useful when there are a 
>> lot of instances in a program. Janus/Ada certainly does this (it might be 
>> the last to do &quot;universal generic sharing&quot;). Some Ada implementations do 
>> &quot;partial generic sharing&quot;, where the parameters involved determine if 
>> sharing is used.
>> 
>> Normally, at this point, I&#39;d say something about premature optimization, but 
>> I realize from your past messages that you&#39;re already beyond that stage, so 
>> I won&#39;t say any more.
> 
> Using DG is a choice like using OO.

DG is "dangerous goods" or "differential geometry"?

> Languages seem to be very keen to add features to support OO programming.
> The zero run time cost is 'potential' because all types can be statically
> determined at compile time. GNAT does this (maybe because it shares a
> backend with C++)

GNAT does this because in Ada static dispatch is always zero run-time cost.
This gives full advantages of OO over generics with no performance loss.

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



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Signature Package With Generic Proceedure
  2012-07-24  8:43             ` Dmitry A. Kazakov
@ 2012-07-24  8:59               ` Keean Schupke
  0 siblings, 0 replies; 12+ messages in thread
From: Keean Schupke @ 2012-07-24  8:59 UTC (permalink / raw)
  Cc: mailbox

On Tuesday, 24 July 2012 09:43:03 UTC+1, Dmitry A. Kazakov  wrote:
> On Tue, 24 Jul 2012 01:02:55 -0700 (PDT), Keean Schupke wrote:
> 
> &gt; On Tuesday, 24 July 2012 03:53:20 UTC+1, Randy Brukardt  wrote:
> &gt;&gt; &amp;quot;Keean Schupke&amp;quot; wrote in message 
> &gt;&gt; ...
> &gt;&gt; &amp;gt; This is datatype generic programming, one of the things I thought Ada is 
> &gt;&gt; &amp;gt; good at.
> &gt;&gt; &amp;gt; Signatures are the only way in Ada of doing this with no runtime cost, and 
> &gt;&gt; &amp;gt; the only way
> &gt;&gt; &amp;gt; using generics. Signatures belong to a family of constructs across several 
> &gt;&gt; &amp;gt; languages with
> &gt;&gt; &amp;gt; similar properties. For example:
> &gt;&gt; 
> &gt;&gt; There&amp;#39;s nothing in Ada that says generics have to be implemented with &amp;quot;no 
> &gt;&gt; runtime cost&amp;quot;. Many Ada 83 implementations, and a few more recent 
> &gt;&gt; implementations, share all generic instantiations. The effect is very 
> &gt;&gt; similar to tagged type dispatching, and it&amp;#39;s most useful when there are a 
> &gt;&gt; lot of instances in a program. Janus/Ada certainly does this (it might be 
> &gt;&gt; the last to do &amp;quot;universal generic sharing&amp;quot;). Some Ada implementations do 
> &gt;&gt; &amp;quot;partial generic sharing&amp;quot;, where the parameters involved determine if 
> &gt;&gt; sharing is used.
> &gt;&gt; 
> &gt;&gt; Normally, at this point, I&amp;#39;d say something about premature optimization, but 
> &gt;&gt; I realize from your past messages that you&amp;#39;re already beyond that stage, so 
> &gt;&gt; I won&amp;#39;t say any more.
> &gt; 
> &gt; Using DG is a choice like using OO.
> 
> DG is &quot;dangerous goods&quot; or &quot;differential geometry&quot;?
> 
> &gt; Languages seem to be very keen to add features to support OO programming.
> &gt; The zero run time cost is &#39;potential&#39; because all types can be statically
> &gt; determined at compile time. GNAT does this (maybe because it shares a
> &gt; backend with C++)
> 
> GNAT does this because in Ada static dispatch is always zero run-time cost.
> This gives full advantages of OO over generics with no performance loss.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

DG is Datatype Generic programming, its a different way of working to Object Oriented design, focusing on algorithms and concepts (or type-classes or signature packages). It has many advantages over OO with potentially better performance.

Cheers,
Keean.  



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-07-26 16:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <045f7b44-2a4a-4292-80fd-0b6bc8ee3465@googlegroups.com>
2012-07-21 22:22 ` Signature Package With Generic Proceedure Adam Beneschan
2012-07-22  7:28   ` Dmitry A. Kazakov
2012-07-22 16:22   ` Keean Schupke
2012-07-23  0:45     ` Adam Beneschan
     [not found]       ` <79925d0c-b2dd-44a3-9451-48f0ee19485f@googlegroups.com>
     [not found]         ` <500d3a9d$0$6566$9b4e6d93@newsspool4.arcor-online.net>
2012-07-23 18:29           ` Keean Schupke
     [not found]         ` <ac8bfaed-dbcc-491a-a760-c25672445eef@googlegroups.com>
2012-07-23 19:41           ` Keean Schupke
2012-07-24  2:57         ` Randy Brukardt
     [not found]         ` <jul2n4$af5$1@munin.nbi.dk>
2012-07-24  8:02           ` Keean Schupke
2012-07-24  8:43             ` Dmitry A. Kazakov
2012-07-24  8:59               ` Keean Schupke
2012-07-23 10:26 ` Simon Wright
2012-07-23 18:36   ` Keean Schupke

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