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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2866100c9a2b8ce7 X-Google-Attributes: gid103376,public From: progers@acm.org Subject: Re: Type conversion between access types (was: Free'ing extended types) Date: 1996/05/23 Message-ID: <4o22no$9ej@uuneo.neosoft.com>#1/1 X-Deja-AN: 156331576 references: <3183AC75.335C@ehs.ericsson.se> organization: NeoSoft Internet Services +1 713 968 5800 reply-to: progers@acm.org newsgroups: comp.lang.ada Date: 1996-05-23T00:00:00+00:00 List-Id: In , bobduff@world.std.com (Robert A Duff) writes: >In article , >Scott Leschke wrote: >>So what about 'all' causes the conversion to be allowed? I looked at >>section 4.6 of the LRM but got a tad confused? > >If you write "all", then it's called a "general access type". 4.6(13) >allows conversion from an access type (general or pool-specific) to a >general access type. 4.6(21) says that if the target type doesn't fall >into one the cases allowed previously, then you can only convert within >the same tree of derived types. (I suspect that derived access types >are unusual, so that would probably not apply.) Derived access type conversion is unusual, at least in my experience, but it sure is handy when you need it (in this case to prevent infinite recursion on "="): package Dynamic_Strings is type Text is limited private; function "="( Left, Right : Text ) return Boolean; ... private type Internal is access String; type Text is new Internal; end Dynamic_Strings; package body Dynamic_Strings is function "="( Left, Right : Text ) return Boolean is begin if ( Internal(Left) = null ) and ( Internal(Right) = null ) then return True; elsif ( Internal(Left) = null ) xor ( Internal(Right) = null ) then return False; -- since one points to an object & the other to nada else -- both refer to objects... return ( Left.all = Right.all ); end if; end "="; ... end Dynamic_Strings; pat --------------- Patrick Rogers progers@acm.org