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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ad988eb0a9545c86 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-13 17:06:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!iad-peer.news.verio.net!news.verio.net!sea-read.news.verio.net.POSTED!not-for-mail Newsgroups: comp.lang.ada From: Brian Rogoff Subject: Re: Problem trying to implement generics. In-Reply-To: Message-ID: References: <9b46dr$cd8$1@taliesin.netcom.net.uk> <9b6jtu$4is$2@taliesin.netcom.net.uk> <9b6m27$68e$1@taliesin.netcom.net.uk> <0JBB6.10484$FD1.1197250@news6-win.server.ntlworld.com> <9b7tce$laf$2@taliesin.netcom.net.uk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Sat, 14 Apr 2001 00:05:48 GMT NNTP-Posting-Host: 206.184.139.136 X-Complaints-To: abuse@verio.net X-Trace: sea-read.news.verio.net 987206748 206.184.139.136 (Sat, 14 Apr 2001 00:05:48 GMT) NNTP-Posting-Date: Sat, 14 Apr 2001 00:05:48 GMT Organization: Verio Xref: supernews.google.com comp.lang.ada:6882 Date: 2001-04-14T00:05:48+00:00 List-Id: On Fri, 13 Apr 2001, Robert A Duff wrote: > "Ayende Rahien" writes: > > > BTW, is there any reason why I can't use out parameter with a function? > > Because it's not allowed. ;-) > > Hmm, are we going have this argument again? Oh well, it's kind of fun, > in a time-wasting sort of way. Here goes: > > If I ran the circus, functions would be allowed to have 'out' and 'in > out' parameters. Or, would you just allow procedures to return values? ;-) Oh well, you're right, this is a time waster (but just too fun to ignore:). > Another workaround is to declare a limited type, with a component that > always points to itself: > > type T is tagged limited > record > Self_Reference: T_Ptr := T'Unchecked_Access; > ... > end record; > > If you pass this thing as an 'in' parameter to a function, the function > can modify it by following the Self_Reference pointer. This works > because no constant objects of type T can exist. It seems a lot like > "cheating", doesn't it? Did anyone see this during the Ada 95 design? I thought J.P. Rosen (who showed most of us this evil trick :) said something about having noticed it early but never actually implementing it until later. I'm sure I'm botching the story: J.P, what's the history here? -- Brian