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 16:09:46 +0200
Date: 2013-08-02T16:09:46+02:00	[thread overview]
Message-ID: <1so729qnkrrj2.ztrxvmlw6cb7.dlg@40tude.net> (raw)
In-Reply-To: 51fb80d8$0$6561$9b4e6d93@newsspool4.arcor-online.net

On Fri, 02 Aug 2013 11:50:15 +0200, Georg Bauhaus wrote:

> Translating to Ada, and with reference to generic formal types, I can
> indicate a category of types. There are no formal classes.

Whatever.
 
>> 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.
> 
> View 1:
> 
> The nature of formal generic specifications is not one whose
> instantiations will produce typed instances, because the latter
> is not defined, or intended, in Ada. In a different theory,
> things will appear differently.
> 
> View 2:
> 
> Not all generic formals allow indicating the "formal classes"
> you find important WRT "belonging", but don't care to say what
> a "formal class" is, or what "belonging" might mean WRT outreach
> and"verifiable substitutability".

I don't understand what you are trying to say here.

> For example, a formal type may be one that has T as an ancestor,
> T giving enough of verifiable information such that each
> instance specifies sets of values that objects will assume
> as a consequence of certain operations.

If this is a proper class already there is no need to introduce a formal
generic class for it. Generic classes are useful when they cannot be spelt
by regular means. Generics are all about patching deficiencies of the type
system. With the type system brought in order, you will need no generics.

>> 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.
> 
> If something *is* known at compile time, but *could* be different for
> a different compilation,

There is only one compilation of the program. Each compilation produces
another program.

> Choosing generics can remove the disadvantages of the unneeded "much"
> (πολύς, polys). Simple generics can reduce complexity by removing the
> overhead of polymorphic dummy parameters of a single, specific type.

Removing parameter in which sense? Compare removing parameter of sine as an
example (in order to reduce complexity of course). The result is a
different object, a number. Function is not number. If you can reduce
generics to non-generics it is no generics. Good riddance.

> For example, if
> you'd want a callback to be passed somewhere. Then, dismissing generics
> might entail the introduction of one level of indirection (subprogram
> pointer),

There is no need in using pointers in order to achieve downward closures.
It was a kludge of Ada 95 design. Generics is a kludge of Ada 83 design. I
always prefer proper objects with a dispatching operation over closures
(callbacks), because an object explicitly encapsulates state while the
closure gather everything visible in the context. It is for sloppy
programming style barely reconcilable with Ada. Yet another language design
problem that there is no simple way to declare such singleton types in Ada.

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


  reply	other threads:[~2013-08-02 14:09 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
2013-08-02  9:50       ` Georg Bauhaus
2013-08-02 14:09         ` Dmitry A. Kazakov [this message]
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