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,9625801f07d834 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-06 14:44:44 PST Path: supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!europa.netcrusader.net!4.1.16.34!cpk-news-hub1.bbnplanet.com!bstnma1-snf1.gtei.net!news.gtei.net!USEAST.RATIONAL.com NNTP-Posting-Host: 172.20.21.30 Newsgroups: comp.lang.ada Date: Fri, 6 Apr 2001 17:30:26 -0400 Message-ID: From: "Corey Ashford" References: <9al9mc$jgk2@cui1.lmms.lmco.com> Subject: Re: Default expression only allowed for "in" parameters - why? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Xref: supernews.google.com comp.lang.ada:6592 Date: 2001-04-06T17:30:26-04:00 List-Id: My guess on this is that the default value would be something only the implementation would care about, not the specification of the function, nor the user of the function. It does the user no good to know what the default value is, because he has no way of knowing whether the implementation will use that value or some other value. In other words, it's an implementation detail best left hidden in the implementation. One could make the argument that the body of the function could have a default output value while the spec wouldn't. But this would break the rule that the body's parameter profile must exactly match the spec's profile; and I don't think this is a sufficient reason to break that rule, especially when there is an alternative that's plenty adequate - move the assignment to the beginning of the body. - Corey "Smark" wrote in message news:9al9mc$jgk2@cui1.lmms.lmco.com... > LRM 6.1(19): > A default_expression is only allowed in a parameter_specification > for a formal parameter of mode in. > > I recently had a situation in which it was desirable for me to have > a default value for an "out" parameter of a function. It was something > like: > > procedure Do_Something (Data : in Some_Type; > Status : out Status_Type); > > Normally, Status = Ok. It seemed to me that, rather than setting > Status := Ok at the beginning of my procedure, it would make sense to > just set the default value in the procedure spec. That is: > > procedure Do_Something (Data : in Some_Type; > Status : out Status_Type := Ok); > > It also seemed like a strange idea, because I never recalled seeing > it done. Sure enough, it is prohibited by the LRM. What is the > rationale for this? > > TIA, > Mark >