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.
What I'd really like to say is:
throwawaytmpvar $sql = q{...};
throwawaytmpvar $sql = q{...};
without problems. Of course, "throwawaytmpvar" is a bit long, but you
get the idea.
It should probably be illegal to:
throwawaytmpvar $sql = q{...};
my $sql = q{...}; # Error: temporary became normal lexical
or for that matter even give it a new type:
throwawaytmpvar int $i = 0;
throwawaytmpvar str $i = "oops"; # Error: redefinition of type
There might be other assumptions that this implies. For example, it
might be considered always thread-private and might be required to be a
core, unboxed type. These extra assumptions are only worth it if they
enhance the optimization possibilities surrounding such a value.
--
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback