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,953e1a6689d791f6 X-Google-Attributes: gidfac41,public X-Google-Thread: f79bb,953e1a6689d791f6 X-Google-Attributes: gidf79bb,public X-Google-Thread: fdb77,953e1a6689d791f6 X-Google-Attributes: gidfdb77,public X-Google-Thread: 1108a1,15aa2a43fe2cde80 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,953e1a6689d791f6 X-Google-Attributes: gid103376,public From: jsa@alexandria (Jon S Anthony) Subject: Re: Eiffel and Java Date: 1996/11/03 Message-ID: #1/1 X-Deja-AN: 194077726 sender: news@organon.com (news) references: <55562c$nkd@mulga.cs.mu.OZ.AU> organization: Organon Motives, Inc. newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.sather,comp.lang.java.advocacy,comp.object Date: 1996-11-03T00:00:00+00:00 List-Id: In article <55fduh$6nc@mulga.cs.mu.OZ.AU> fjh@murlibobo.cs.mu.OZ.AU (Fergus Henderson) writes: > jsa@alexandria (Jon S Anthony) writes: > > ]shang@corp.mot.com (David L. Shang) writes: >... > ]> > ]> No. Java supports only top-down class hierarchy construction > ]> (from superclass to subclasses), but not bottom-up: from > ]> subclasses to superclass. > > Why not? I would have thought that since Java has separate interface > inheritence already, it would not be difficult to provide this feature. David Shang wrote that. And, actually, I would tend to agree with you. So, why would Java have a problem here? > ]But in general it is _trivial_ to do in Ada. > > I'm skeptical. :-). Always a wise stance! Clearly I waxed hyperbolic... > ]with Stacks; -- Generic > ]with Queues; -- Generic > ]generic > ] type Any_Obj is tagged private; > ]package Stack_Or_Queue > ] > ] package S is new Stacks(Any_Obj); > ] package Q is new Queues(Any_Obj); > ] > ] type Any is access all Any_Obj'Class; > ] type Stack_Queue ( S : access S.Stack; Q : access Q.Queue ) is private; > ]... > ]procedure Push (Element : Any; Onto : Stack_Queue); > ]function Pop (SQ : Stack_Queue) return Any; > ]... > ]private > ] type Stack_Queue ... > ]... > ]end Stack_Or_Queue; > > Can I use this stack_or_queue interface to access different > implementations of the stack type (e.g. using arrays or using > linked lists?) Yes. > How about priority_queues? You mean something like, how does this work if you keep extending the queues? That should be OK. If you mean something like, I have a _different_ priority_queue thingy here (not derived from queues) - will it just fit in and work? No, that will require going back and futzing... > With the Sather version, anything that implements push and pop can be > declared to implement the stack_or_queue interface. Good point. > It looks like your stack_or_queue interface has exactly two > implementations and can't be extended. (And that's despite being > much more verbose and complicated than the Sather version.) It has exactly two sorts of _interfaces_ (despite being more verbose and complicated). You can have different implementations of these and that should still work. /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com