Path: news.daimi.aau.dk!olm From: olm@daimi.aau.dk (Ole Lehrmann Madsen) Newsgroups: comp.lang.eiffel,comp.lang.beta,comp.lang.java.advocacy Subject: Re: Java and Eiffel - Further comments: I am depressed. Date: 20 Apr 1997 21:49:20 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 175 Message-ID: <5je310$gc$1@gjallar.daimi.aau.dk> References: <335725DA.9D0@daimi.aau.dk> <1997Apr18.155308.10494@schbbs.mot.com> NNTP-Posting-Host: ariel.daimi.aau.dk X-Newsreader: NN version 6.5.1 (NOV) Xref: news.daimi.aau.dk comp.lang.eiffel:28736 comp.lang.beta:11045 comp.lang.java.advocacy:7942 In the (included) posting below from David Shang the following question is asked: > By the way, since BETA has a unified concept, how does it support > the above? In general, a nested pattern (class) in BETA is not different from a pattern (class) defined at the outermost level. So anything you can do with a pattern at the outermost level, you can do with a nested pattern. For the specific questions > 1. Inheritance. Can it extend from another inner class in its > enclosing class's superclass? Here is the example in BETA: A: (# IA: (# #) #); B: A(# IB: IA(# #) #); > 2. Override. Can its implementation be overriden in its enclosing > class's subclasses? In BETA a nested pattern (class) may be declared virtual (similar to virtual function). The definition may be extended in a subclass of its enclosing class. Example: A: (# IA:< (# #) #); B: A(# IA::< (# #) #) IA is declared a virtual pattern of A. IA is extended in B. This mechanism is used to defined parameterized classes in BETA, similar to generic classes in Eiffel. One of my students, Kresten Krab Thorup, has a paper at ECOOP'97 in June on how to introduce parameterized types in Java based on virtual patterns. (Contact krab@daimi.aau.dk if you are interested in this) > 3. Isolation. Can its implmentation be separated from its interface? In BETA the definition of one or more patterns may be separated into an interface file and an implementation file using the so-called fragment system. (Like in Modula 2 and Ada). This is also possible for nested patterns. It is difficult to argue for nested classes via news postings like this one. If you are really interested in nested classes, you should try it out for yourself. It is highly recommendable. ---olm References --------- 1. O.L. Madsen, Block Structure and Object-Oriented Languages. In (B.D. Shriver, P. Wegner, eds.) Research Directions in Object-Oriented Programming. MIT Press, 1987. 2. Ole Lehrmann Madsen, Birger Moller-Pedersen, Kristen Nygaard: Object-oriented programming in the BETA programming language. Addison-Wesley, June 1993, ISBN 0 201 62430 3 *************** BETA information Sources *********************************** WWW: http://www.mjolner.dk http://www.daimi.aau.dk/~beta News: comp.lang.beta FAQ: http://www.daimi.aau.dk/~beta/FAQ E-mail: info@mjolner.dk Address: Mjolner Informatics, Science Park Aarhus, Gustav Wieds Vej 10, DK-8000, Aarhus C, DENMARK Tel.: +45 86 20 20 00 Fax.: +45 86 20 12 22 ***************************************************************************** In <1997Apr18.155308.10494@schbbs.mot.com> shang@corp.mot.com (David L. Shang) writes: >In article <335725DA.9D0@daimi.aau.dk> Gorel Hedin writes: >> >> No, inner classes in Java are true nested classes as in Simula and BETA >> where objects of inner classes live in the context of an object of the >> outer class, and can access instance variables and methods in the outer >> object. In contrast, the "nested classes" in C++ is only a way of >> organizing name spaces and does not have any effect on the objects at >> runtime. >> >> True nested classes is a powerful programming feature which is not >> available in C++. >> >Since Java does not unify the concept of "method" and "inner class", >my question is that, does Java's inner class support: >1. Inheritance. Can it extend from another inner class in its > enclosing class's superclass? >Example in Transframe: > class A > { > class IA > { > } > }; > class B is A > { > class IB is IA > { > } > }; >2. Override. Can its implementation be overriden in its enclosing > class's subclasses? >Example in Transframe: > class A > { > class IA (interface1), (interface2) > { > enter (interface1) > { > // interface1 implementation > } > enter (interface2) > { > // interface2 implementation > } > } > }; > class B is A > { > class IA (interface1) > { > enter (interface1) > { > // interface1 implementation override > } > } > }; > x: A; > x := B(); > x.IA (parameters_match_interface1); // call the one in B::IA >3. Isolation. Can its implmentation be separated from its interface? >Example in Transframe: > interface class A > { > class IA (interface1), (interface2); > // interface IA > }; > class implementationA is A > { > class IA (interface1), , (interface2) > { > // implelemtation of IA > } > }; >By the way, since BETA has a unified concept, how does it support >the above? >David Shang