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,e5eb8ca5dcea2827 X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Ada OO Mechanism Date: 1999/06/09 Message-ID: #1/1 X-Deja-AN: 487307132 References: <7i05aq$rgl$1@news.orbitworld.net> <7i17gj$1u1k@news2.newsguy.com> <7icgkg$k4q$1@nnrp1.deja.com> <3749E9EC.2842436A@aasaa.ofe.org> <7id2eo$fag@drn.newsguy.com> <3749FF7D.F17CE16A@aasaa.ofe.org> <374AC676.F7AE0772@lmco.com> <7ieuja$5v9@news1.newsguy.com> <7ifd6l$bmf@sjx-ixn1.ix.netcom.com> <1999Jun8.151014.1@eisner> NNTP-Posting-Date: Tue, 08 Jun 1999 18:23:15 PDT Newsgroups: comp.lang.ada Date: 1999-06-09T00:00:00+00:00 List-Id: Hyman Rosen writes: > Also, I stated in an earlier message that I thought not allowing T'Class > variables in records was not orthogonal, but understandable in light of > the above. Now, suppose I need a function that returns a pair of values, > one of which is a T'Class and the other a boolean. Is there a way to do > this? Not really, no. Here are some ideas: 1) return a record containing a class-wide component allocated on the heap type RT is record O : T_Class_Access; B : Boolean; end record; function Func_Ret_RT return RT; 2) Break in the function apart into two functions: function Func_Ret_T_Tic_Class return T'Class; function Func_Ret_Boolean return Boolean; This doesn't preserve atomicity, however. (But that's not always an issue anyway.) 3) Embed the Boolean value in state of the object: function Func_Ret_T_Tic_Class return T'Class; function Func_Ret_Boolean (O : T) return Boolean; > I can't return a record containing the pair, because I can't have > such a record. That is correct. Although, if you follow approach 1), you can put the class-wide value on the heap. > I assume that a procedure with a pair of out parameters won't work, > because the T'Class variable which receives the output must be > initialized when declared, and then its tag can't change. Yes, that is correct. > So, is there a way? See the three bullets above.