comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: C++0x : no 'concepts'
Date: Wed, 9 Sep 2009 17:42:22 +0200
Date: 2009-09-09T17:42:22+02:00	[thread overview]
Message-ID: <1hva3l5mqlw0i$.ia3ssy3z8uva$.dlg@40tude.net> (raw)
In-Reply-To: 4aa7c007$0$30230$9b4e6d93@newsspool1.arcor-online.net

On Wed, 09 Sep 2009 16:47:34 +0200, Georg Bauhaus wrote:

> Dmitry A. Kazakov schrieb:
> 
>>> Fantasizing, could we have, in Ada,
>>>
>>> - recursive instantiations of pure generics?
>> 
>> Huh, the second edition of interfaces, now for the "Ada preprocessor"? I
>> read you that all instances of the same body when instantiated
>> automatically will be considered "same". Right?
> 
> No, I was thinking of this:
> 
> generic
>    N : Natural := (if N = 0
>                      then 1
>                      else new Factorial'(N * Factorial(N - 1)));
> function Factorial return Positive;
> 
> pragma Pure(Factorial);

I see, PL/1's preprocessor:

%DO I=0 TO 255;
...  -- I don't remember the mess
%END;

Shudder.

----------------
What I meant was rather:

generic
   type Number is digit <>;
   with package Arithmetic is new Generic_Arithmetic (T);
package Generic_Vectors is ...

when Generic_Vectors is instantiated with Float it instantiates
Generic_Arithmetic as necessary. This is instead of putting an
instantiation into Generic_Vectors's declarative part because we want to
share the same instance of Generic_Arithmetic with other generic packages
instantiated with Float.

Typically you have a cloud of generic packages started with a priming type
like Float. It is a torture to instantiate them manually, inventing a
naming scheme for them, and then dealing with 1K source files resulting
from. The disaster is aggravated by instantiations within generic packages.
In the end nobody knows why the program does not compile and what is
instantiated where.

The problem with automatic instantiation is that when instances have
data/elaboration code etc, it will be a hell to tell if two instances are
same or not. The situation is identical to MI. In fact it is a form of MI,
just based on the static polymorphism.

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



  reply	other threads:[~2009-09-09 15:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-09 11:44 C++0x : no 'concepts' Martin
2009-09-09 12:12 ` Georg Bauhaus
2009-09-09 12:15   ` Martin
2009-09-09 12:39   ` Dmitry A. Kazakov
2009-09-09 14:47     ` Georg Bauhaus
2009-09-09 15:42       ` Dmitry A. Kazakov [this message]
2009-09-09 14:49 ` Adam Beneschan
2009-09-09 19:26   ` sjw
2009-09-10  0:16 ` wwilson
2009-09-10  0:45   ` Keith Thompson
2009-09-10 23:36     ` Stephen Leake
2009-09-11  4:36       ` wwilson
2009-09-11 10:10 ` John McCabe
replies disabled

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