言語の設計判断
- 68. >>> def foo():
... x = "static"
... def bar():
... print(x)
...
... bar()
...
>>> foo()
static
- 69. sub foo{
my $x = "staticn";
my $bar = sub{
print $x;
}
&bar();
}
&foo(); #-> static
- 71. sub foo{
my $bar = sub{
print $x;
};
$bar->();
}
$x = "globaln";
&foo(); #-> global
{
local $x = "dynamicn";
&foo(); #-> dynamic
}
&foo(); #-> global