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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a1a88c4d509f6381 X-Google-Attributes: gid103376,public From: fluffy_doo@dsuper.net Subject: Re: scope and/or parameters (beginner) Date: 1999/04/05 Message-ID: <370b0c99.1137352783@news.dsuper.net>#1/1 X-Deja-AN: 463158868 Content-Transfer-Encoding: 7bit References: <37064309.889106243@news.dsuper.net> <37084459.8616007@rocketmail.com> Content-Type: text/plain; charset=us-ascii Organization: Delphi SuperNet Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-04-05T00:00:00+00:00 List-Id: On Mon, 05 Apr 1999 05:04:25 +0000, Corey Ashford > ... >"IN" parameters are considered read-only. You've tried to pass it to >a procedure which may attempt to change its value - something that >isn't allowed to a read-only variable. Treat "IN" parameters as >constants that are defined when the subprogram is invoked. > >[snip] >Well, you could change the definition of One_prog so that its >Second_Variable is of type "IN OUT The_Type", instead of just IN. Then >you could call Inner_Procedure legally with Second_Variable. > >- Corey But that is part of my main objective: to have it as "IN" in the first subprogram (One_Procedure), and then as "IN OUT" for the subprogram one level below (Internal_Procedure). It's just an exercise I've made for myself to help me better understand the formal/actual parameter manipulation. I want Var_2 to remain unchanged at the main program level. Let's say I want to use that variable (its original value) later in the program, in a subprogram called directly from the main program, which is why I insist on having an "IN" parameter in One_Procedure. 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. This exercise, in part learning to use "named" instead of "positional" association, has allowed me to realize the following, I think : The fact that a sub-program is declared INSIDE another, as opposed to OUTSIDE of it, makes no difference from the point of view of the compiler. As long as any call to a sub-program is made AFTER its declaration it is treated exactly the same way. TRUE / FALSE ? Thanks again. How come the people in this group are so helpful and straight forward, much more than in other groups I've frequented before ? Is this part of some organized campain with the purpose of popularizing Ada ? It is a if the people here were paid to do it and truly enjoyed it on top of it ! Marc Galipeau -- What I really am is "fluffy", no "_dong", no "_puff", no "_woo", no nothing, just plain fluffy.