One common mistake many novice programmers make involves attempting to assign to a parameter name which has already been assigned a value. Darwin does not allow a new value to be assigned to the parameter. They may however be assigned a new undefined name. The following two versions of DummyProc exemplify this subtle difference of how Darwin treats a symbol and a value.
> DummyProc1 := proc( inside ) > inside := 1; # assign to inside the value 1 > end: > outside := 2; > DummyProc1( outside ); # an error Error, (in DummyProc1) invalid left hand side in assignment > DummyProc2 := proc( inside ) > inside := b; # assign to inside a symbol b > end: > outside := a; > DummyProc2( outside ); # now outside has symbol b assigned > print(outside); # to it.In the first example DummyProc1, we are attempting to assign the value 1 to the parameter inside. Darwin does not like this and reports an appropriate error. In the second example, DummyProc2, we are attempting to assign the name b to the parameter name. This is entirely legal.
If you are not confused yet, then try to explain the following behaviour:
> DummyProc3 := proc( inside ) > bb := 7; > inside := bb; # assign to inside a symbol b > end: > outside := aa: > DummyProc3( outside ); # now outside has symbol b # assigned to it. 7 > print(outside); aaHere we have indirectly assigned the value 7 to the parameter inside. However, the change does not persist after the execution of the procedure.