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,d0452dbe16ac0df4 X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Re: ObjectAda vs Gnat -- bugs Date: 1997/05/20 Message-ID: <01bc656a$a0307400$LocalHost@xhv46.dial.pipex.com>#1/1 X-Deja-AN: 242772346 References: <5loibn$qek@lotho.delphi.com> Organization: UUNet PIPEX server (post doesn't reflect views of UUNet PIPEX) Newsgroups: comp.lang.ada Date: 1997-05-20T00:00:00+00:00 List-Id: Jon S Anthony wrote in article ... > In article <5loibn$qek@lotho.delphi.com> tmoran@bix.com writes: > > > So if I wanted to make some reusable object with the characteristics: > > constant once created > > creation requires info not conveniently done with discriminants > > limited > > one approach would be to make the type T limited and tell users to declare > > X : T renames Create(...); > > Right? > > Works for me... > No, I don't agree. I think the "renames" is potentially misleading. An alternative approach would be: X: T; -- X initialised to an unusable status begin Init(X,...); -- X now set up as required The first parameter of procedure X would be of type "in out T". This may be uglier than the above solution, but it would be less misleading, and it might be more flexible in some situations (as arbitrary processing can precede the call to Init). Any attempt to use X before it had been properly set up could be detected and raise an exception. If X needs to be constant once set up, any attempt to call Init again on X could also be detected and raise and exception. Nick.