Pref::warnLexProcEnv --
warnings about usage of variables from lexical scope
IntroductionPref::warnLexProcEnv() returns the current
setting.
Pref::warnLexProcEnv(TRUE) switches on
parser warnings about the usage of variables from the lexical
scope.
Pref::warnLexProcEnv(FALSE) switches
warning messages off.
Pref::warnLexProcEnv(NIL) will reset the
default value, which is FALSE.
Call(s)Pref::warnLexProcEnv()
Pref::warnLexProcEnv(TRUE)
Pref::warnLexProcEnv(FALSE)
Pref::warnLexProcEnv(NIL)
Returnsthe previously defined value; TRUE or FALSE
Side
EffectsAllows or suppresses warning messages of the parser.
Further
Documentationchanges
Related
FunctionsPref::warnChanges, Pref::warnDeadProcEnv,
proc
DetailsPref::warnLexProcEnv is enabled the parser warns if
a procedure defined in the lexical scope of another procedure uses
variables from its lexical scope.Pref::warnDeadProcEnv switches
on warnings about the critical usage of the lexical scope.
Example
1Here you can see a procedure which computes the square
of its argument in a very complicated way. The inner procedure
g makes use of the variable x of procedure
f, thus a warning is given. But this is no problem, since
g does not escape its scope. See Pref::warnDeadProcEnv about
problems of procedure leaving its scope.
>> Pref::warnLexProcEnv(TRUE): f := proc(x) local g; begin g := y -> x*y; g(x) end: f(5)
Warning: Procedure '->' is referring outer lexical closure \
[col 42]
25