-
Notifications
You must be signed in to change notification settings - Fork 148
Description
The fact that FORM forces users to follow the strict order of statements gives unnecessary complexity for some cases.
Consider a procedure containing executable statements with local $-variables, for example,
#procedure Foo()
$FooPRIVATEx = term_;
* Use $FooPRIVATEx locally.
#endprocedure
which can be called like
if (count(SomeLabel,1));
#call Foo()
endif;
A problem occurs when one wants to parallelize the program, which requires ModuleOption local,$FooPRIVATEx at the end of the module due to the order of the statements.
A solution for this would be to pass temporary $-variables as arguments of a procedure
#procedure ProcWithManyTempVars(tmp1,...,tmp9)
`tmp1' = term_;
* ...
#endprocedure
* ...
#call ProcWithManyTempVars(<$tmp1>,...,<$tmp9>)
* ...
ModuleOption local,<$tmp1>,...,<$tmp9>;
.sort
Another solution that I saw is to make an additional procedure just for the module options
#procedure ProcWithManyTempVars()
$procPRIVATEx = term_;
* ...
#endprocedure
#procedure ProcWithManyTempVarsModuleOptons()
ModuleOption local,$procPRIVATEx;
* ...
#endprocedure
* ...
#call ProcWithManyTempVars()
* ...
#call ProcWithManyTempVarsModuleOptions()
.sort
But it would be smart to allow ModuleOption local to be at any places. Then we could write
#procedure Foo()
$FooPRIVATEx = term_;
* Use $FooPRIVATEx locally.
ModuleOption local,$FooPRIVATEx; * Nice if allowed!
#endprocedure
A test implementation is at tueda@loosedecl. This patch also relaxes the order for some of declarations (for example Symbols) such that the following code works
#procedure deriv(x)
S derivPRIVATEy;
id `x'^derivPRIVATEy? = derivPRIVATEy * `x'^derivPRIVATEy / `x';
#endprocedure
S y;
L F = y^3;
#call deriv(y)
#call deriv(y)
P;
.end
Am I missing any potential problems that could be caused by this change?