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,953e1a6689d791f6 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/05 Message-ID: #1/1 X-Deja-AN: 194752204 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-05T00:00:00+00:00 List-Id: In article eachus@spectre.mitre.org (Robert I. Eachus) writes: > In article jsa@alexandria (Jon S Anthony) writes: > > > 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... > > This looks like a case where you want interface inheritance, so > implement interface inheritance: > > generic > type Stack_or_Queue is limited tagged private; > type Element is tagged private; > with function Pop(SQ: in Stack_or_Queue) return Element'Class is <>; > with procedure Push(E: in Element; Onto: in out Stack_or_Queue) is <>; > with function Is_Empty(SQ: in Stack_or_Queue) return Boolean is <>; > -- etc. > -- your procedure, function, or package goes here. > > For any Stack, Queue, Deque, etc., which matches the interface you > can instantiate your generic. You can even figure out a meaningful > definition of Is_Empty for a queue connected to a pipe if that is what > you have. (For example, delay until the other end of the pipe is > closed and return false, or until another element is put into the pipe > and return true.) Right. Actually, what occured to me after I wrote that was that this sort of example should be dealt with by means of generic formal package parameters. After all, defining this sort of "generic" signature is one of the very things that they were defined for... I suppose (since I've gone this far along) that I should write up the example using this technique. I am pretty sure it will be about exactly what one wants in this sort of case. /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com