comp.lang.ada
 help / color / mirror / Atom feed
From: fluffy_dong@dsuper.net
Subject: Re: scope and/or parameters (beginner)
Date: 1999/04/15
Date: 1999-04-15T03:54:22+00:00	[thread overview]
Message-ID: <37155f01.1945002895@news.dsuper.net> (raw)
In-Reply-To: wcchfqkbddr.fsf@world.std.com

On Tue, 13 Apr 1999 18:10:08 GMT, Robert A Duff
<bobduff@world.std.com> wrote:

>fluffy_doo@dsuper.net writes:
>
>> It looks like I am forced to declare a *new variable* in One_Procedure
>> to which I will give the value of Var_2 (Ex: modif_Var_2 := Var_2;),
>> and then send modif_Var_2 in Internal_Procedure to be modified and
>> brought back via its "IN OUT" parameter.
>
>That's right.
>
>The rule in some other languages (eg Pascal and C) is different -- in
>those languages, a parameter acts just like a local variable, so you can
>modify it, and it doesn't affect the caller's copy.  That's error prone,
>which is why in Ada an 'in' mode parameter acts like a local *constant*.
>
>- Bob

What I'm surprised about is not about a passage through a single
sub-program, but through two (2) of them in line, two levels down.  I
would have expected the IN parameter to protect the value against
modification only for the sub-program from which it was first passed
but not for the second one.  As it stands, if a variable is passed
down several sub-programs, it must keep the same passage mode
throughout the entire line.  I wonder why they made it this way.

It would have seemed logical to make it so that an IN passage from A
to B (only when B is declared INSIDE A) could have allowed an IN OUT
of the same variable from B to C (C being inside B) to modify the
value IN B BUT NOT IN A.  This would have avoided the additional
variable needed but would have still protected the variable's
integrity in A.  There would be no danger in inadvertantly affecting
it via another sub-program declared outside of A because both B and C
are declared inside A, and therefore not visible outside of it.

One significant change it would have made would have been that formal
parameters would behave differently depending on weather or not a
sub-program is declared inside another or not, which  I believe is not
the case now (in today's real world of Ada).  I have a feeling there
is a good reason, a more specific one, why it is the way it is.  If
it's not too complicated to explain, maybe someone can  try to tell
me.

Marc  
--
What I really am is "fluffy", no "_dong",
no "_puff", no "_woo", no  nothing, just plain fluffy.






  parent reply	other threads:[~1999-04-15  0:00 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-02  0:00 scope and/or parameters (beginner) fluffy_pink
1999-04-03  0:00 ` Matthew Heaney
1999-04-05  0:00 ` Corey Ashford
1999-04-05  0:00   ` fluffy_doo
1999-04-06  0:00     ` Matthew Heaney
1999-04-08  0:00     ` czgrr
1999-04-10  0:00       ` fluffy_puff
1999-04-12  0:00       ` dennison
1999-04-13  0:00         ` czgrr
1999-04-13  0:00           ` Robert Dewar
1999-04-14  0:00             ` czgrr
1999-04-14  0:00               ` dennison
1999-04-14  0:00               ` Robert Dewar
1999-04-15  0:00                 ` czgrr
1999-04-15  0:00                   ` Robert Dewar
1999-04-13  0:00         ` Robert Dewar
1999-04-13  0:00     ` Robert A Duff
1999-04-14  0:00       ` Robert Dewar
1999-04-14  0:00         ` Hyman Rosen
1999-04-14  0:00           ` dennison
1999-04-14  0:00             ` Hyman Rosen
1999-04-14  0:00               ` dennison
1999-04-14  0:00                 ` Hyman Rosen
1999-04-15  0:00                   ` dennison
1999-04-15  0:00                     ` Robert Dewar
1999-04-15  0:00                       ` dennison
1999-04-15  0:00                       ` Hyman Rosen
1999-04-15  0:00           ` Robert Dewar
1999-04-15  0:00             ` Hyman Rosen
1999-04-15  0:00               ` Robert Dewar
1999-04-15  0:00                 ` Hyman Rosen
1999-04-16  0:00               ` Rakesh Malhotra
1999-04-15  0:00       ` fluffy_dong [this message]
1999-04-15  0:00         ` Robert Dewar
1999-04-15  0:00           ` dennison
1999-04-15  0:00             ` fluffy_dong
1999-04-16  0:00               ` Robert Dewar
1999-04-16  0:00                 ` Fraser Wilson
1999-04-16  0:00                   ` Gautier.DeMontmollin
1999-04-20  0:00                     ` Nick Roberts
1999-04-21  0:00                     ` fraser
1999-04-22  0:00               ` Robert A Duff
1999-04-22  0:00                 ` Larry Kilgallen
1999-04-16  0:00         ` Samuel Mize
replies disabled

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