From: Ken Garlington <GarlingtonKE@lmtas.lmco.com>
Subject: Re: Converting C++ class to Ada
Date: 1996/12/12
Date: 1996-12-12T00:00:00+00:00 [thread overview]
Message-ID: <32B05137.733A@lmtas.lmco.com> (raw)
In-Reply-To: JSA.96Dec11160847@alexandria
Jon S Anthony wrote:
>
> Two ways:
>
> 1. type Object_Type (
> X_Motor : Motor_Access_Type;
> Y_Motor : Motor_Access_Type;
> X_Limit : Switch_Access_Type;
> Y_Limit : Switch_Access_Type ) is null record; (or better: is private)
>
> Now, whenever an object of this type is declared, you will have to supply
> the discriminants and there you are. Note that this works for the case of
> _limited_ types too.
However, will I be able to update the discriminants? Norman Cohen points
out that I could have an updatable copy within the record, but
that seems a little clumsy. Also, if I wanted to make sure that "null"
wasn't used as one of the discriminants, would I have to use "access
Motor.Object_Type" rather than the declared access type?
> 2. type Object_Type (<>) is private;
> function Make (
> X_Motor : Motor_Access_Type;
> Y_Motor : Motor_Access_Type;
> X_Limit : Switch_Access_Type;
> Y_Limit : Switch_Access_Type ) return Object_Type;
> ...
> private
> type Object_Type is record ... as you have it
> OR
> type Object_Type (... as in 1.
>
> Now, whenever an object of this type is declared you will have to
> initialize it. The only way you give is via Make, so you can force
> the supply of arguments. This way is especially useful with instances
> of limited types via allocators as you can have your own pool and know
> all clients must use that pool.
OK. This looks like it might be a winner. I'll try it and see.
> Right. Except I don't see this as simply a "style" issue. It is more
> important than that. The C++ hack..ah..coder goofed and should have made
> the motor and switch stuff private (or protected).
OK. I'm trying not to stray too far from the C++ code, since I would
like
for C++ folks to be able to compare it with the Ada version, but I think
in this case I'll make an exception and make it private.
--
LMTAS - The Fighter Enterprise - "Our Brand Means Quality"
For job listings, other info: http://www.lmtas.com or
http://www.lmco.com
next prev parent reply other threads:[~1996-12-12 0:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-12-10 0:00 Converting C++ class to Ada Ken Garlington
1996-12-11 0:00 ` Jon S Anthony
1996-12-12 0:00 ` Ken Garlington [this message]
1996-12-18 0:00 ` Jon S Anthony
1996-12-18 0:00 ` Matthew Heaney
1996-12-19 0:00 ` Robert A Duff
1996-12-20 0:00 ` Stephen Leake
1996-12-20 0:00 ` Robert A Duff
1996-12-20 0:00 ` Jon S Anthony
1996-12-20 0:00 ` Mitch Gart
1996-12-20 0:00 ` Norman H. Cohen
1996-12-21 0:00 ` Jon S Anthony
1996-12-11 0:00 ` Norman H. Cohen
1996-12-12 0:00 ` Jon S Anthony
1996-12-11 0:00 ` Larry Kilgallen
1996-12-11 0:00 ` Stephen Leake
1996-12-13 0:00 ` Stephen Leake
1996-12-12 0:00 ` Dale Stanbrough
1996-12-12 0:00 ` Constructors for Ada (was: Converting C++ class to Ada) Matthew Heaney
1996-12-13 0:00 ` Norman H. Cohen
1996-12-13 0:00 ` Matthew Heaney
1996-12-17 0:00 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox