comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: Default expression only allowed for "in" parameters - why?
Date: Mon, 9 Apr 2001 10:42:17 -0400
Date: 2001-04-09T14:42:19+00:00	[thread overview]
Message-ID: <9ashob$q93$1@nh.pace.co.uk> (raw)
In-Reply-To: GBEMM2.LoD@world.std.com

Just a thought: The use of defaults for in-out and out might be more of a
matter of interest at the call to the procedure rather than at the procedure
itself. With a default specified, the parameter could be ignored. If a
procedure passes back a status indication as an out parameter and the caller
doesn't care, the caller can ignore it because of the default. (O.K. it
looks a little funny - why does an initializer mean you can ignore the
parameter? Just because that's how you specify an ignorable parameter when
it is an in parameter.) Likewise, if the caller doesn't provide an in-out
parameter, one is created with the initial value assigned and then ignored
on return. The called procedure goes along fat, dumb and happy not knowing
that no actual was provided at the call.

I suppose there are other mechanisms possible for saying "this is an
ignorable parameter" but since Ada used a default assignment to an in
parameter to indicate this, I'd go with it for in-out and out as well. I've
seen a number of instances where I've wanted to have parameters to a
subprogram that the caller might sometimes want to use and might sometimes
choose to ignore. It would be useful to have such a mechanism and might make
Ada a little more C-ish {wash out my mouth with soap!} in terms of being
able to create subprograms with variable parameter lists.

The only reason I could think of for not doing this might be some argument
for safety. Is this the sort of thing that would be dangerous to include in
the language because of likely programmer errors that could not be detected?
I don't know that a case could be made for this, but maybe there is one. (If
it is error prone, then wouldn't the ignorable in parameters be likewise
dangerous?)

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Ben Brosgol" <brosgol@world.std.com> wrote in message
news:GBEMM2.LoD@world.std.com...
> 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.
>






  reply	other threads:[~2001-04-09 14:42 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
2001-04-09 14:42     ` Marin David Condic [this message]
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