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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4180a73b05d119c7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-01 06:51:07 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!paloalto-snf1.gtei.net!mtvwca1-snh1.ops.genuity.net!washdc3-snh1.gtei.net!washdc3-snf1!news.gtei.net!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!53ab2750!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <3E890A20.8080108@attbi.com> Subject: Re: ML-like alternatives to out parameters for functions X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Tue, 01 Apr 2003 14:51:06 GMT NNTP-Posting-Host: 141.157.177.80 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny02.gnilink.net 1049208666 141.157.177.80 (Tue, 01 Apr 2003 09:51:06 EST) NNTP-Posting-Date: Tue, 01 Apr 2003 09:51:06 EST Xref: archiver1.google.com comp.lang.ada:35860 Date: 2003-04-01T14:51:06+00:00 List-Id: "Robert I. Eachus" wrote in message news:3E890A20.8080108@attbi.com... > Note that this does not mean you cannot write functions in Ada that > alter their parameters. > > function Random(Gen: in Generator) return Uniformly_Distributed is > Local_Gen: Generator; > for Local_Gen'Address use Gen'Address; > begin... > > is perfectly legal Ada. It may be legal code, but the question arises as to whether this is good code. In most cases, parameter modes are an aid to both the compiler and the programmer, telling them when we can assume that an actual parameter could be altered and when its state will remain the same. In the case of the Random function, however, the parameter mode is a lie. The function specification indicates that the Gen parameter is not modified by a call to Random, even though we all know that it does indeed get modified. This is an inelegant kludge, and it stands out as a blemish on the predefined packages, which for the most part are very well designed.