comp.lang.ada
 help / color / mirror / Atom feed
From: "Corey Ashford" <x@y.com>
Subject: Re: Default expression only allowed for "in" parameters - why?
Date: Fri, 6 Apr 2001 17:30:26 -0400
Date: 2001-04-06T17:30:26-04:00	[thread overview]
Message-ID: <E166E69A95753648BC398E36BE9A3AB80DD4769D@sus-ma1it06.rational.com> (raw)
In-Reply-To: 9al9mc$jgk2@cui1.lmms.lmco.com

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" <not.provided@all.com> 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
>





  reply	other threads:[~2001-04-06 21:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-06 20:41 Default expression only allowed for "in" parameters - why? Smark
2001-04-06 21:30 ` Corey Ashford [this message]
2001-04-06 21:49 ` Robert A Duff
2001-04-07  4:19   ` Ben Brosgol
2001-04-09 14:42     ` Marin David Condic
2001-04-09 15:08   ` Smark
2001-04-10 13:59     ` Martin Dowie
2001-04-07 14:12 ` Charles H. Sampson
2001-04-07 18:17   ` Ben Brosgol
2001-04-09 14:07 ` Marin David Condic
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox