I don't like the distinction between "anonymous" and other blocks.
On Tue, 8 Aug 2000 17:44:56 +0100, Graham Barr wrote:
>How usable is this ?
>
>I may be missing something, but if every variable mentioned in an anonymous
>block is assumed to be declared with my, then how do you access or modify
>the value of any variable outside the block ?
Applescript does something like "use scoped 'subs'". Everything is local
to a sub, except global variables which you must declare as global.
Exactly the opposite as with perl's "local". It's a bit limited, but it
works rather well.
I can imagine that you may expand this idea, burning holes in the shield
so to say, and letting specific variables through. For example:
$x = 5;
{
$x = 10;
{
use outer '$x'; # or: outer($x);
print $x;
$x = 20;
}
print $x;
}
print $x;
This would print 10 (the $x from the middle block), 20 (same $x,
modified), and 5 (the unmodified $x from the outmost block -- the script
file).
I can think that "import" instead of "outer" would be a nice name, too.
A whole different meaning than in other languages, true.
--
Bart.