I have a variable in a package (rec
in this case) that needs to be set when called from package 3
, but it's private. Previously the function set_true
only set rec
to true, so it wasn't a big deal. But I have another package that does the same processing (I'm giving a simple example, but my literal case is more complex), so I thought, well I could pass in the variable I want modified, and let it get changed. Is the only way to set rec
in the below layout, to create a second function in package one, that calls set_true
with rec
as the parameter? I would like to avoid having to keep creating additional functions to handle the local variables. I can't move the variable to public (spec) as I am trying to follow convention and this "type" of variable isn't public anywhere else, and I don't want anyone to be able to just set it on their own (I want functions to have to set). I don't want to have to create a second function named for example set_local_true
, and creating an overloaded function set_true
, with no parameters, that calls set_true(value => rec)
just seems deceptive, does anyone have any better suggestions with the limitations I have?
My two requirements:
- Can't make the local variable public.
- Be able to use the function to calculate something both externally and internally.
package one is
procedure set_true(value : out Boolean);
end one;
package body one is
rec : Boolean;
begin
procedure set_true(value : out Boolean)
begin
value := true;
end set_true;
end one;
package body two is
local_rec : Boolean;
begin
procedure call_function is
begin
one.set_true(value => local_rec);
end call_function;
end two;
package body three is
begin
procedure call_function is
begin
one.set_true(value => <PACKAGE ONE'S REC))
end call_function;
end three;
EDIT: Or perhaps, what would be a better naming convention for the functions to specify that they are modifying the variable that is local to that package? Set_Local_True
again is deceptive cause if you call it from package 3, you're not setting your local true, you're setting package one's local to true....