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-17 06:26:06 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!fr.clara.net!heighliner.fr.clara.net!RENT.THIS.SPACE.FOR.ADVERTISING!feed2.onemain.com!feed1.onemain.com!feeder.qis.net!washdc3-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: Problem trying to implement generics. Date: Tue, 17 Apr 2001 09:20:32 -0400 Organization: AverStar (formerly Intermetrics) Burlington, MA USA Message-ID: <3ADC4320.7ACA3DEC@averstar.com> 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> NNTP-Posting-Host: nebula.burl.averstar.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 987513629 14891 141.199.8.77 (17 Apr 2001 13:20:29 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 17 Apr 2001 13:20:29 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:6948 Date: 2001-04-17T13:20:29+00:00 List-Id: 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. It would be interesting to see where such functions would typically be used. My experience is that the most common uses for such functions are: 1) Returning a status value (probably better handled with exceptions in Ada) 2) Using in a "while" loop, such as: while Get_Next(Iterator, Val) loop ... end loop; My own objection to having functions with OUT parameters is that it increases the possibility for confusion for the reader. When you see a procedure call, there is little doubt that it is being called for its side-effects. When you see a function call (except in certain stylized locations such as the "while" condition above), you presume it is being called for its value, or at least it won't directly change the value of some elementary parameter passed to it. I wonder if we might create a new loop syntax to accommodate the "while" case above, without opening up the function-with- out-parameters box. Alternatively, just get used to one of the idioms: loop Get_Next(Iterator, Val, Done); exit when Done; ... end loop; or while More(Iterator) loop Get_Next(Iterator, Val); ... end loop; Interestingly enough, the standard Iterator in Java uses: while (Iter.hasNext()) { X = Iter.next(); ... } even though Java has functions with side effects (although in fact, only with side-effects on by-reference operands, since it has no parameter modes at all!). -Tuck > > - Bob > > P.S. One workaround is to use access parameters. Note, that "C" uses essentially the same "workaround" since C has no "out" parameters. -- -Tucker Taft stt@avercom.net http://www.averstar.com/~stt/ Chief Technology Officer, AverCom Corporation (A Titan Company) Burlington, MA USA (AverCom was formerly the Commercial Division of AverStar: http://www.averstar.com/services/ebusiness_applications.html)