comp.lang.ada
 help / color / mirror / Atom feed
From: "Ben Brosgol" <brosgol@world.std.com>
Subject: Re: Default expression only allowed for "in" parameters - why?
Date: Sat, 7 Apr 2001 04:19:28 GMT
Date: 2001-04-07T04:19:28+00:00	[thread overview]
Message-ID: <GBEMM2.LoD@world.std.com> (raw)
In-Reply-To: wccvgohvgv7.fsf@world.std.com

Robert A Duff <bobduff@world.std.com> wrote in message
news:wccvgohvgv7.fsf@world.std.com...
> "Smark" <not.provided@all.com> writes:
>
> > 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?
>
> If defaults were allowed for 'out' params, I would think it ought to
> mean that this is the default variable to pass to the parameter, not a
> default initial value for it.

I agree with Bob.

> In Ada, a default applies if the
> parameter is not explicitly given at the call site.  Are you saying that
> Status should be initialized to OK if the actual parameter is specified?
>
> Defaults for 'out' params were allowed in Green.  I don't know why they
> were removed.  Perhaps the fact the you and I disagree on what they
> ought to mean is a hint.

If memory serves, the reason for the absence of defaults for 'out' and 'in
out' parameters was methodological.  A variable is passed as an [in] out
parameter in order to be modified, and the design team felt that this effect
should be explicit at the point of call, by the explicit presence of an
actual parameter.  In any event the capability (of default [in] out objects)
would probably not be too useful, since the default would need to be an
object visible at the procedure declaration whereas it is more typical for
an actual to be local to the scope in which the procedure is called.

Ben Brosgol
Ada Core Technologies
brosgol@gnat.com






  reply	other threads:[~2001-04-07  4:19 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
2001-04-06 21:49 ` Robert A Duff
2001-04-07  4:19   ` Ben Brosgol [this message]
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