>> Having the subscript operator change the topic is, IMHO, a rather strong
>> violation of the principle of least surprise.
> 
> I'm inclined to agree. I think I'd much rather not have it change there, 
> since I'll frequently do stuff like this:
> 
> my %hash;
> for qw(one two three) {
>     %hash{$_} = 1; # $_ should *not* == %hash here!
> }
> 

Yes, this is one of the reasons we're hesitant to do it. Even though it does
give you lovely slice idioms like:

        @public = %hash{ /^(<-[_]>.*)/ };

And, if we *did* go that way, your example would become:

        my %hash;
        for qw(one two three) -> $key {
             %hash{$key} = 1;
        }

which doesn't seem a terribly high price to pay.

On the other hand, too many topicalizing contexts actually reduce the 
intrinsic value of topics themselves, since the current topic then doesn't 
hang around long enough to actually be useful. I suspect that it the clincher 
against this idea.

Damian

Reply via email to