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,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e5eb8ca5dcea2827 X-Google-Attributes: gid103376,public X-Google-Thread: 1008e3,a7084fcfbc5ce2fb X-Google-Attributes: gid1008e3,public From: "Vladimir Olensky" Subject: Re: Ada OO Mechanism Date: 1999/05/31 Message-ID: <928161154.329.88@news.remarQ.com>#1/1 X-Deja-AN: 484081934 References: <7i05aq$rgl$1@news.orbitworld.net> <7i17gj$1u1k@news2.newsguy.com> <7icgkg$k4q$1@nnrp1.deja.com> <3749E9EC.2842436A@aasaa.ofe.org> <7id2eo$fag@drn.newsguy.com> <3749FF7D.F17CE16A@aasaa.ofe.org> <374AC676.F7AE0772@lmco.com> <374F1DD3.64070C3E@mitre.org> <7ircia$ued@drn.newsguy.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: newsabuse@remarQ.com X-Trace: 928161154.329.88 K3TLTKYJOA5C9C7F8C qube-02.us-ca.remarq.com Organization: Posted via RemarQ Communities, Inc. NNTP-Posting-Date: Mon, 31 May 1999 14:32:34 GMT Newsgroups: comp.lang.ada,comp.lang.modula3 Date: 1999-05-31T00:00:00+00:00 List-Id: chris@nospam wrote in message <7ircia$ued@drn.newsguy.com>... > >In Modula-3, you have a modula, which is same as an Ada package. >but also, you have what is called an OBJECT, (which looked >like a RECORD), which contains DATA part, and METHODS part. > >Inside a modula, you can declare an OBJECT. > >So, here we have a language, which I thought was very similar to >Ada, but used the familiar class like construct for the OO type. ============================================== As a matter of fact M3 allows you to use both ways to invoke methods on objects if my nemory serves me right. ---------------------------------------------------------------------------- ------ -- Object.method and method (object) are both valid calls for M3. ---------------------------------------------------------------------------- ------ It just depends on the intention of the Interface Module designer who allows you to use one of them or both (first one in most cases). Usually implementation modules use the method (object) syntax but it is hidden from the user (as the implementation is not visible to customer). As M3 allows to have several different interfaces to the same implementation module (exploiting so called partial revelation) so it is possible to have two sets of operation (with different syntax) to be in the different interfaces to given implementation as well. M3 is extremely flexible regarding this. Moreover, depending on how you defined your object methods you may even allow user to redefine object methods during program execution (just changing procedure address in VMT). (e.g.during execution you can create array of bytes representing some chain of assembler instructions and then call it when needed). It is just an example, more safe is to have object method which can call any other procedure with the given profile. If anyone have a look at M3 sources he/she can find there a lot of extremely interesting things. May be M3 experience will be considered seriously some time in the future. I wonder why Averstar sells and supports only Ada 95 and Modula-GM. It would be logical to have M3 in the list of it's products . It would be very impressive set: Ada 95, . AppletMagic, Modula-3, Modula-GM. Regards, Vladimir Olensky Here some code from M3 sources as an illustration: ------------------------------------- INTERFACE GO; EXCEPTION PropUndefined; EXCEPTION StackError; TYPE Shape = {Complex, NonConvex, Convex, Unknown}; TYPE T <: Public; Public = ProxiedObj.T OBJECT METHODS init () : T; setName (name : TEXT); getName () : TEXT; pushMouseCB (cb : MouseCB.T); popMouseCB () RAISES {StackError}; END; ---------------------------------------------------------------------------- ---- Copyright (C) 1994, Digital Equipment Corp. Created by Marc Najork MODULE GO EXPORTS GO, GOPrivate; REVEAL T = Private BRANDED OBJECT OVERRIDES init := Init; setName := SetName; getName := GetName; pushMouseCB := PushMouseCB; popMouseCB := PopMouseCB; END; PROCEDURE Init (self : T) : T = BEGIN self.props := NIL; self.damaged := TRUE; self.name := NIL; self.dl := 0; self.mouseCBstack := NEW (MouseCBStack.T).init (); self.positionCBstack := NEW (PositionCBStack.T).init (); self.keyCBstack := NEW (KeyCBStack.T).init (); RETURN self; END Init; PROCEDURE SetName (self : T; name : TEXT) = BEGIN self.name := name; END SetName; PROCEDURE GetName (self : T) : TEXT = BEGIN RETURN self.name; END GetName; PROCEDURE PushMouseCB (self : T; cb : MouseCB.T) = BEGIN self.mouseCBstack.push (cb); END PushMouseCB; PROCEDURE PopMouseCB (self : T) RAISES {StackError} = BEGIN self.mouseCBstack.pop (); END PopMouseCB; BEGIN Transform := NEW (Transform_PN).init (Matrix4.Id); END GO.