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,965fbd9798ca1677 X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: Return by reference Date: 1999/11/03 Message-ID: #1/1 X-Deja-AN: 544255901 References: <38203d4a_1@news1.prserv.net> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 941691329 212 bpr@206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-03T00:00:00+00:00 List-Id: On Wed, 3 Nov 1999, Matthew Heaney wrote: > In article > , Brian Rogoff wrote: > > > I was going to use the "Rosen trick" to modify data in the Fmt each time > > "&" is called. Unfortunately, that requires making the full view of > > Format_Type limited and you run into the problem I described. > > > > Is there a cleaner way to implement that interface? > > 1) Privately implement the type as tagged, to make it a by-reference > type. > > 2) This allows you to invoke RM95 13.3 (16), to take the address of > parameter. > > 3) Pass the address to an instantiation of > System.Address_To_Access_Conversions, which gives you a variable view of > the parameter. Interesting idea. I'll try it, but it still does more copying than I'd have liked, since it isn't a return-by-reference type. You'll end up copying on the way out. > Note that there has been a subtle error running throughout this thread. > There is nothing wrong with returning a "by-reference" type as a > function return type; the error is returning a *limited* type. No, I was quite clear in my post. The issue is about "return-by-reference" types (see 6.5.11) and why returning an argument of such a type is the same as returning a local variable of such a type (it is the same, in that it raises Program_Error). You can certainly return a (limited) return-by-reference type from a function, it just has to be global to that function. -- Brian > > > -- > Science is, foremost, a method of interrogating reality: proposing > hypotheses that seem true and then testing them -- trying, almost > perversely, to negate them, elevating only the handful that survive to > the status of a theory. Creationism is a doctrine, whose adherents are > interested only in seeking out data that support it. > > George Johnson, NY Times, 15 Aug 1999 > >