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: 103376,900edaa189af2033 X-Google-Attributes: gid103376,public From: Ken Garlington Subject: Re: Ada95 OOP Questions Date: 1996/08/14 Message-ID: <321206C2.1F26@lmtas.lmco.com>#1/1 X-Deja-AN: 174227637 references: <4tf3l4$4hu@masala.cc.uh.edu> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Tactical Aircraft Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.02 (Macintosh; I; 68K) Date: 1996-08-14T00:00:00+00:00 List-Id: Jon S Anthony wrote: > > In article ecn@explorer2.clark.net (Eric C. Newton) writes: > > > It's a pretty hard sell to say (pardon the syntax, 8-): > > > > struct Person; > > Eat(Person); > > Walk(Person); > > Talk(Person); > > > > "That's a person. It has the features 'Eat, Walk, Talk'." > > > > Vs. > > class Person > > { > > Eat(); > > Walk(); > > Talk(); > > }; > > > > I see no reason why _passive_ entities (the so called objects for > either of the above) should look like they are acting or being > commanded to act. If you want that then use an activity which in Ada > would be modeled by a task: Here's a more convoluted way to get the syntax in the "right" order. Granted, it exposes state variables that should be hidden, but by God the syntax is right! package Person is type State is private; Initial_State : constant State; type Activity is access procedure ( Using : in out State ); procedure Eating ( Using : in out State ); procedure Walking ( Using : in out State ); procedure Talking ( Using : in out State ); type Object is tagged record Eat : Activity := Eating'Access; Walk : Activity := Walking'Access; Talk : Activity := Talking'Access; Current_State : State := Initial_State; end record; private type State is record Stomach_Level : Natural; X_Coordinate : Natural; Y_Coordinate : Natural; Volume : Natural; end record; Initial_State : constant State := (0,0,0,0); end Person; with Person; procedure Person_Test is Joe : Person.Object; begin Joe.Eat(Using => Joe.Current_State); Joe.Walk(Using => Joe.Current_State); Joe.Talk(Using => Joe.Current_State); end Person_Test; :) -- LMTAS - "Our Brand Means Quality"