comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Generics vs. O-O?
Date: Fri, 2 Aug 2013 10:11:32 +0200
Date: 2013-08-02T10:11:32+02:00	[thread overview]
Message-ID: <15qso6tlt3uf1.h45wqc019b00$.dlg@40tude.net> (raw)
In-Reply-To: 51fadf40$0$6557$9b4e6d93@newsspool4.arcor-online.net

On Fri, 02 Aug 2013 00:20:47 +0200, Georg Bauhaus wrote:

> On 01.08.13 21:24, Dmitry A. Kazakov wrote:
> 
>> 7. Formal generic types of Ada are weakly typed. Matching is by structure.
>> User-defined generic types (ADTs) are not supported. User-defined
>> operations on formal types are not supported. The language of formal
>> generic parameters is somewhere between FORTRAN-IV and K&R C.
> 
> Not quite far from a misrepresentation of Ada generics.
> Nothing in the languages mentioned can require type equivalence
> by name in whatever generic formals, as in
> 
> package N is
> 
>    type T is range -1 .. 1;
> 
>    generic
>      type S is new T;
>    package Pointless is end;
> 
>    type Q is range -1 .. 1;
> 
>    package Exmpl is new Pointless (Q);  -- error
> 
> end N;
> 
> Equivalent structure of scalar types T and Q won't do.

You cannot specify what belongs to a formal class it is decided by the
structure of given type.

Regarding your example the class you used is one created outside the
generics. It is good that Ada 95 allowed this, but it does not change the
nature of the language of formal generic specifications.

>> 9. Generic units are basically non-testable. Substitutability issues are
>> difficult to verify because of 7.
> 
> With generics, substitutability issues arise as soon as one wishes to subsume
> the mechanism of generic units under a formally extraneous type systems.
> So, judicious use of this language features for things other than typing
> might be the better choice.

Here substitutability encompasses all parameters generics take, not just
types. E.g.

generic
   with function Foo (X : Integer) return Real;
package Bar is ...

You cannot verify if Baz

   function Baz (X : Integer) return Real;

were substitutable in Bar for Foo.

One of the motivations beyond types engaging in complex relationship was to
limit the framework where substitution is considered.

Parametric polymorphism of generics is way too loose, because it basically
untyped. Worse is that it is any useful so long it remains untyped. Once
you try to put types on it, it will be as "inconvenient" as any type
system, while keeping all disadvantages of being strictly compile-time.

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

  reply	other threads:[~2013-08-02  8:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01 14:45 Generics vs. O-O? Eryndlia Mavourneen
2013-08-01 19:24 ` Dmitry A. Kazakov
2013-08-01 19:52   ` Eryndlia Mavourneen
2013-08-01 20:14     ` sbelmont700
2013-08-01 23:35       ` Yannick Duchêne (Hibou57)
2013-08-01 20:10   ` optikos
2013-08-01 20:26     ` Dmitry A. Kazakov
2013-08-01 20:35     ` Jeffrey Carter
2013-08-01 21:22     ` Bill Findlay
2013-08-01 23:38     ` Yannick Duchêne (Hibou57)
2013-08-01 22:20   ` Georg Bauhaus
2013-08-02  8:11     ` Dmitry A. Kazakov [this message]
2013-08-02  9:50       ` Georg Bauhaus
2013-08-02 14:09         ` Dmitry A. Kazakov
2013-08-02 15:08           ` Shark8
2013-08-02 15:36             ` Alan Jump
2013-08-02 17:00               ` Jeffrey Carter
2013-08-02 17:51               ` Dmitry A. Kazakov
2013-08-02 18:06                 ` Alan Jump
2013-08-02 19:08                   ` Dmitry A. Kazakov
2013-08-02 16:15             ` Dmitry A. Kazakov
2013-08-03  0:04       ` Yannick Duchêne (Hibou57)
2013-08-03  7:35         ` Georg Bauhaus
2013-08-03  8:57           ` Dmitry A. Kazakov
replies disabled

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