comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Dynamic binding
Date: Sat, 14 Apr 2012 10:58:29 +0200
Date: 2012-04-14T10:58:29+02:00	[thread overview]
Message-ID: <w66wxdjrvwmq$.gweq9lki5u9p.dlg@40tude.net> (raw)
In-Reply-To: m28vhyg3sy.fsf@pushface.org

On Sat, 14 Apr 2012 08:39:41 +0100, Simon Wright wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> A is called class-wide in Ada. All calls from it will be dispatching.
>> Class-wide operations represent in Ada the concept of generic
>> programming: operations defined for a whole set of types (the class).
> 
> Looking at the Wikipedia article on generic programming, we have to
> distinguish between _generic programming_ and _genericity mechanisms_;
> but only after we've distinguished between three or more meanings of
> _generic programming_:
> 
> * Ada-style generics, C++ templates ...

= static polymorphism

> * the C++ STL approach of Musser and Stepanov (followed in spirit by 
>   Ada.Containers)

= static polymorphism
 
> * 'datatype generic programming' (I found
>   http://www.cs.ox.ac.uk/research/pdt/ap/dgp/ - but that paper
>   recognises that there are yet other uses of _generic programming_)

= parametric polymorphism, probably static

> Not sure where Dmitry's meaning goes. One of the third type, I think.

One possible way to look how programming is evolving in order to handle
bigger problems is this one. It starts with individual values or objects
(level 1). Then it continues to sets of values sharing some similarities
(factored out as operations). These sets are types (level 2). The next
logical step is to consider similar types (mathematicians would call them
categories). This is generic programming (level 3). You can have
similarities in values of types from the set (e.g. extension, various
products), you can have similarities in operations (e.g.
inheritance/instantiation). It is complicated and still not sorted out with
all issues like LSP etc. I cannot tell anything useful about the level 4...

As for language-technical solutions for the level 3:

1. you can constrain types from a set (dynamically parametric polymorphism:
Ada's discriminated, variant types).

2. you can clone types while adjusting them (statically parametric
polymorphism: Ada's generics, Ada 83 "type is X new Y").

3. you can have types in the set bound by interface+implementation
inheritance (dynamic polymorphism: Ada's tagged types).

4. you can have only interface(-implementation) inheritance using type
conversions (Ada does not have this).

5. you can have it in the form of sets of types with nominally same
operations (ad-hoc polymorphism: overloading in Ada).

Each new level requires new language entities: value->type->class, and
faces the problem whether these should be mapped onto the entities of the
lower level. I.e. should a type be a value/object? What is the type of
value type? Should operations have types? What is the type of a class? Is
an instance from the class an object etc.

> I can see that an alternative name such as _classwide programming_ isn't
> going to fly for the wider public!

Classwide programming would be ambiguous, because it well applies to Ada's
generics:

generic
   type Number is range <>;
function "+" (Left, Right : Number) return Number;

*is* classwide because it is defined on the class Number (all signed
integer types).

Semantically "type S is range <>" and "type S derived from T" are just sets
of types. Only construction of these sets are different.

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



  reply	other threads:[~2012-04-14  8:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13 20:13 Dynamic binding Katarina Olsson
2012-04-13 20:55 ` Dmitry A. Kazakov
2012-04-14  6:41   ` Niklas Holsti
2012-04-14  7:39   ` Simon Wright
2012-04-14  8:58     ` Dmitry A. Kazakov [this message]
2012-04-15 12:04 ` AdaMagica
  -- strict thread matches above, loose matches on Subject: below --
2012-04-13 20:11 Katarina Olsson
2012-04-14  8:43 ` Georg Bauhaus
2012-04-14 17:17   ` Simon Wright
replies disabled

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