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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public From: Brian Rogoff Subject: Re: OO, C++, and something much better! Date: 1997/02/21 Message-ID: #1/1 X-Deja-AN: 220511685 References: <5bphq4$5js@mulga.cs.mu.OZ.AU> <5eka6l$bv1@nerd.apk.net> Content-Type: TEXT/PLAIN; charset=US-ASCII Mime-Version: 1.0 Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c++,comp.lang.smalltalk,comp.object Date: 1997-02-21T00:00:00+00:00 List-Id: On 21 Feb 1997, Eric W. Nikitin wrote: > Chris Bitmead (Chris.Bitmead@Alcatel.com.au) wrote: > : Not true. There are other definitions of type. > : > : For example, in some languages we could have a "ball" class and a > : "cat" class, both of which respond to the message "kick", yet there is > : no explicit "kickable" class. > > In languages like Oberon-2 ( and I am fairly certain like Ada as well ), > these concerns are modeled by separate language constructs. Encapsulation > is provided by modules, structure comes from the type mechanism, and > behavior is described by dynamically-bound procedures. > > A language derived from Oberon, Lagoona, goes on to provide an additional > feature called categories which are distinct from type, but allow > different types to be related via similar behaviors. ( Categories > are similar to protocals in Objective-C and interfaces in Java ). Something similar to this is provided in Ada by using generic packages with empty bodies. For example generic type Item is private; procedure Kick( X : in out Item ); package Kickable_Sig is end; with the canonical example being a mathematical group generic type Element is private; Identity: in Element; with function Op(X, Y: Element) return Element; with function Inverse(X: Element) return Element; package Group is end; Note that the programmer need not have provided a procedure named "Kick" for Cat or Ball, any procedure with the specified signature will do in the instantiation: package Kickable_Ball is new Kickable_sig(Element => Soccer_Ball, Kick => Soccer_Kick); -- Brian