Code: Select all
Global myVar.l
Procedure Add2(myVar.l)
ProcedureReturn myVar + 2
EndProcedure
When you share/reuse a procedure that contains a parameter named e.g. dir.s but this variable name is used somewhere else in the new code as a global variable, you have to substitute all the 'dir' inside the procedure or the new main code with a worse selfexplaining word.
Because of this I would prefer that parameters are always handled as protected variables.
Of course then you couldn't access a global variable of the same name , but that's no problem, because the coder of a procedure knows it's global name-environment and what for global vars he want to use, if some, but (s)he cannot know the global variable-name-environment used in another code, so this point rans more into a conflict than giving an advantage.
The shared-command could override this behaviour, even if then the parameter gets 'lost':
This should give 23:
Code: Select all
Global myVar.l
myVar = 999
Procedure Test(myVar.l)
Debug myVar
EndProcedure
Test(23)
Code: Select all
Global myVar.l
myVar = 999
Procedure Test(myVar.l)
Shared myVar
Debug myVar
EndProcedure
Test(23)
Or have I overlooked a handicap ?