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,34d47d048b177d0b X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: limited/non-limited in Ada95 Date: 1997/10/18 Message-ID: #1/1 X-Deja-AN: 281590314 Distribution: world References: <3442C2A3.3781@bix.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-10-18T00:00:00+00:00 List-Id: In article , Jon S Anthony wrote: >mheaney@ni.net (Matthew Heaney) writes: > >> What "important capabilities" do limited types have? That they're passed >> by reference? You get that for free anyway for tagged types, even if the >> tagged type is non-limited. > >Well, they are _not_ necessarily passed by reference. That is part of >what Henry Baker is (correctly) whinging about. > >The most important part is that they can't be implicitly aliased - >especially via assignment. I don't understand Henry's problem. If I implement a bank account as package Bank_Accounts is type Bank_Account is limited private; ... private type Bank_Account is limited record Money : Dollars := 0.0; end record; end; Then what's the problem? Always implement the full view as a limited record. (My only complaint is that you can't apply the limited qualifier to other types, not even arrays. Bummer. So you have to wrap the type in a limited record. Oh well.) I agree that aliasing can comprimise the safely of a limited type (everyone ought to read Baker's Limited Robbery paper), but if the programmer always implements a limited private type by using a full view that is itself limited - which one can do in Ada 95 - then there is no problem. If the programmer doesn't use a by-reference type, then it's a case of programmer indolence, not a language problem. All the same, it would be really swell if compilers would tell you when you implement a limited private type using a type that isn't passed by reference. It would be cool too if that were added as an argument to pragma Restrictions, something like Full_View_Of_Limited_Private_Must_Be_Limited. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271