Larry Wall:
# That binds the dynamically surrounding $_ to $x as an 
# out-of-band parameter.  Can also bind to $_ to make it the 
# current topic.

The problem I have with that is this:

        sub for_trace(*@array, &block) {
                loop($_=0; $_ < @array; $_++) {
                        print "$_:\n";
                        
                        {
                                my $coreprint=&CORE::print;
                                my $lastnl=1;
                                                
                                temp &CORE::print := sub ($fh: *@args) {
                                        $fh.$coreprint("\t") if $lastnl;
                                        
                                        $fh.$coreprint(@args);
                                        
                                        $lastnl = @args[@args.last] =~
/\n $/;
                                }
                        
                                block(@array[$_]);
                        }
                        
                        print "\n"
                }
        }
        
        $_="x";
        @list=qw(y z);
        
        for_trace @list -> $x {
                print $_;
        }

Which of these does this print?

        0:
                0
        1:
                1

        0:
                y
        1:
                z

        0:
                x
        1:
                x

The "correct" behavior (IMHO) is the third, though I could see the
second.  But the first is unacceptable.

--Brent Dax <[EMAIL PROTECTED]>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

Wire telegraph is a kind of a very, very long cat. You pull his tail in
New York and his head is meowing in Los Angeles. And radio operates
exactly the same way. The only difference is that there is no cat.
    --Albert Einstein (explaining radio)

Reply via email to