Variable typing
Alex Tweedly
alex at tweedly.net
Tue Apr 4 12:30:22 EDT 2006
Robert Sneidar wrote:
> The problem is, Revolution script is soooo friendly with variable
> typing that just passing an undefined variable name as an arguement
> to a function will simply pass the variable name as a literal to the
> parameter of the called function, so within the function, no matter
> what, the value of the parameter will be something. It would be nice
> if Revolution did not do that, but I understand they need to be
> compatible with prior xCard solutions.
>
If you set "explicitVariables" in the IDE, you will get errors for
undefined variables (and if you declare the variable as a local within
the handler, then it will be initialized to empty) - so avoiding some of
the difficulties you have to deal with below. Of course, you still can't
distinguish between a variable which is undefined and one which has been
deliberately set to empty :-(
> Once inside the function, variableNames and globalNames knows nothing
> of a local variable in the calling handler. And there is no way to
> distinguish if the parameter passed is the value of an existing
> variable, or the literal name of the variable I thought I was passing
> it. Revolution is simply being too friendly. Passing the variable as
> a reference doesn't help either. The parameter is still resolved to
> the value of the passed variable regardless, (which begs the question
> "what's the difference?") In short, there is no way for a called
> function to tell if a variable belonging to the scope of the calling
> script exists or not, and what it is. Until now.
>
Hmmmm - how about the case of :
on myHandler
local myVar
put "myVar" into myVar
put "myVar" into varName
put theType(myVar, varName) into myType
-- function theType() returns a type of "U" which is wrong
end myHandler
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.5/300 - Release Date: 03/04/2006
More information about the use-livecode
mailing list