From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e9c183f3911c2d73 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.227.230 with SMTP id sd6mr4532553pbc.8.1334393920287; Sat, 14 Apr 2012 01:58:40 -0700 (PDT) Path: r9ni54687pbh.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Dynamic binding Date: Sat, 14 Apr 2012 10:58:29 +0200 Organization: cbb software GmbH Message-ID: References: <32a3d08f-7b48-46e2-b8cf-004acb6e40a3@d4g2000vbn.googlegroups.com> <55tfbsnll3t0$.1hx68o0qdhb90$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: Gbl624r6iuNIccy3ASy5ag.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-04-14T10:58:29+02:00 List-Id: On Sat, 14 Apr 2012 08:39:41 +0100, Simon Wright wrote: > "Dmitry A. Kazakov" 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