adding null character to a name (24.4.01)

Greg Nash

Adding a null character to a name, shouldn’t affect it’s interpretation:


However, when doing the same thing in a procedure, this same behavior doesn’t seem to apply:


What am I missing?

Helmut Kahovec (26.4.01)

Well, you are missing the following (cf. online help page of cat):

”Note that if the result of cat is a name, then it is in fact a global name, even though there might be a local variable of the same name currently active.”

and

”This allows you to make global assignments from within procedures. It illustrates the fact that only global names are returned by cat.”

(the latter being the comment on the last example of that online help page). Thus we have in turn:



Robert Israel (29.4.01)

Actually you’re not adding anything to the name. But you can’t construct a local variable inside a procedure. The constructed name refers to the global variable x, not the local variable of the procedure. See my Maple Advisor Database page ?Constructing_names_of_local_variables_and_formal_parameters (http://www.math.ubc.ca/~israel/advisor):

The reason for this behaviour is connected to the way the Maple kernel processes procedure definitions. Internally, names are used for reference to global variables, but not local variables or formal parameters. For example:

> test3:= proc(x) local v; v:= x+g end: 
> pointto(disassemble(addressof(eval(test3)))[6]); 
 
                        LOC[1] := args[1] + g

Thus in the internal version of the procedure definition, the local variable name v is replaced by LOC[1], and the formal parameter name x is replaced by args[1] (more precisely, these are special constructions which Maple interprets as references to the first local variable and the first formal parameter). If a name is only produced when the procedure is executed, these replacements do not occur and the name is interpreted as a global variable.