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: 109fba,2f84446733b06aca X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,2f84446733b06aca X-Google-Attributes: gid103376,public From: Ken Garlington Subject: Re: Converting C++ class to Ada Date: 1996/12/12 Message-ID: <32B05137.733A@lmtas.lmco.com>#1/1 X-Deja-AN: 203749041 references: <32ADF183.7195@lmtas.lmco.com> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Tactical Aircraft Systems mime-version: 1.0 newsgroups: comp.lang.ada,comp.lang.c++ x-mailer: Mozilla 3.01 (Win95; U) Date: 1996-12-12T00:00:00+00:00 List-Id: 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