On Fri, Apr 15, 2005 at 11:45:16AM -0400, Aaron Sherman wrote:
: Among the various ways of declaring variables, will Perl 6 have a way to
: say, "this variable is highly temporary, and may be re-declared within
: the same scope, or in a nested scope without concern"? I often find
: myself doing:
:
: my $sql = q{...};
: ...do some DB stuff...
: my $sql = q{...};
: ...do more DB stuff...
:
: This of course results in re-defining $sql, so I take out the second
: "my", but then at some point I remove the first one, and strict chews me
: out over not declaring $sql, so I make it "my" again.
:
: This is a cycle I've repeated with dozens of variations on more
: occasions than I care to (could?) count.
And at that point, why not just change it to this?
my $sql;
$sql = q{...};
...do some DB stuff...
$sql = q{...};
...do more DB stuff...
It seems to me that assignment does a pretty good job of clobbering a
variable's value without the need to redeclare the container. If you
really want to program in a definitional paradigm that requires every
new definition to have a declaration, then you ought to be giving
different definitions different names, seems like, or putting each
of them into its own scope. Or write yourself a macro. Or just turn
off the redefinition warning...
It doesn't seem to rise to the level of a new keyword for me.
Larry