Re: A92: quirks


[Prev][Next][Index][Thread]

Re: A92: quirks



Jeff Tyrrill wrote:
> You said there is no problem if you Define f(x)=x^2, and then type f(x). It
> does return x^2, but try typing f(x+2). It then gives a circular definition
> error, where f(y+2) returns the correct answer, (y+2)^2. This is the reason it
> is recommended to use uncommon names for arguments when defining a function.
Yes, I see now that this does happen, but I don't see the logical
justification for it.  There is no reason that you should be unable to
pass x+2 as an argument to the function f(x)=x^2.  The manual states
that a function's parameter variables are local to that function.  Thus
the global "x" variable accessible from the home screen should have no
relation whatsoever to the local "x" variable accessible only within the
function "f".
The circular definition error would make perfect sense if the function
"f" were using the global "x" variable, but it isn't.  It's using its
own local "x".
Page 304 of the manual has a note that says, "Because xx and yy in the
function are local, they are not affected by any existing xx or yy
variable."
On the same page, "Remember to use argument names in the definition that
will never be used when calling the function."
These two statements seem to contradict each other.
Are a function's parameter variables indeed local?

--Andrew
asieber@usa.net


Follow-Ups: References: