comp.lang.ada
 help / color / mirror / Atom feed
From: Ken Garlington <garlingtonke@lmtas.lmco.com>
Subject: Re: Ada95 OOP Questions
Date: 1996/08/14
Date: 1996-08-14T00:00:00+00:00	[thread overview]
Message-ID: <321206C2.1F26@lmtas.lmco.com> (raw)
In-Reply-To: 4tf3l4$4hu@masala.cc.uh.edu


Jon S Anthony wrote:
> 
> In article <dahgq78i0z.fsf@explorer2.clark.net> 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"




  parent reply	other threads:[~1996-08-14  0:00 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-28  0:00 Ada95 OOP Questions Spasmo
1996-07-28  0:00 ` David C. Hoos, Sr.
1996-07-28  0:00   ` Spasmo
1996-07-28  0:00 ` Andre Spiegel
1996-07-28  0:00   ` Spasmo
1996-07-29  0:00     ` Thomas Kendelbacher
1996-07-31  0:00       ` Spasmo
1996-08-01  0:00         ` Thomas Kendelbacher
1996-08-02  0:00         ` Gene Ouye
1996-08-01  0:00       ` Jon S Anthony
1996-07-30  0:00     ` Ken Garlington
1996-08-04  0:00       ` Spasmo
1996-07-30  0:00     ` David Wheeler
1996-07-31  0:00       ` Spasmo
1996-07-29  0:00 ` Andre Spiegel
1996-07-29  0:00   ` David Wheeler
1996-07-30  0:00     ` Spasmo
1996-07-30  0:00     ` Spasmo
1996-07-29  0:00   ` Thomas Kendelbacher
1996-08-02  0:00     ` Robert Dewar
1996-08-05  0:00       ` Thomas Kendelbacher
1996-08-06  0:00         ` Robert Dewar
1996-08-06  0:00           ` Thomas Kendelbacher
1996-08-06  0:00             ` Robert A Duff
1996-08-07  0:00               ` Robert Dewar
1996-08-08  0:00                 ` Robert A Duff
1996-08-09  0:00                   ` Robert Dewar
1996-08-12  0:00             ` Robert I. Eachus
1996-08-08  0:00           ` Theodore E. Dennison
1996-08-09  0:00             ` Robert Dewar
1996-08-12  0:00             ` Joel VanLaven
1996-08-06  0:00         ` Robert I. Eachus
1996-08-10  0:00         ` Chris Morgan
1996-07-30  0:00 ` Andre Spiegel
1996-07-30  0:00 ` Andre Spiegel
1996-07-30  0:00 ` Robert I. Eachus
1996-08-01  0:00 ` Jon S Anthony
1996-08-13  0:00 ` Eric C. Newton
1996-08-14  0:00 ` Jon S Anthony
1996-08-14  0:00 ` Ken Garlington [this message]
1996-08-14  0:00 ` Eric C. Newton
1996-08-21  0:00 ` Jon S Anthony
  -- strict thread matches above, loose matches on Subject: below --
1996-08-08  0:00 W. Wesley Groleau (Wes)
1996-08-20  0:00 Farshad Nayeri
1996-08-20  0:00 Farshad Nayeri
1996-08-21  0:00 ` Jon S Anthony
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox