Re: Fwd: CPAN Upload: T/TB/TBONE/Parse-RecDescent-FAQ-1.4.tar.gz

[email protected] (Damian Conway)
Newsgroups perl.recdescent
Message-ID <[email protected]>
As promised, I looked through the FAQ.

I can find no factual (FAQ-tual?) errors in it, nor anything that needs
to be rewritten.

Excellent work, Terrence.

I can, however, offer an addendum if you want it:

           Apparent, but not really deep copying:  my (@list) = @{[@{$_[0]}]};

             I was meandering through demo_calc.pl in the
             Parse::RecDescent demo directory and came across this

              sub evalop
              {
                     my (@list) = @{[@{$_[0]}]};
                     my $val = shift(@list)->();
              ...
              }

        I have no recollection of why I did this (see children, that's
        why you should *always* comment your code!).

        I *suspect* it's vestigal -- from a time when contents of the
        argument array reference were somehow modified in situ, but
        it was important that the original argument's contents not
        be changed.

        The ungainly C<@{[@{$_[0]}]}> syntax is a way of (shallow)
        copying the array referenced in $_[0] without declaring a new
        variable. So another possible explanation is that evalop may
        originally have been a one-liner, in which case I might have
        used this "inlined copy" to keep the subroutine's body to a
        single expression.

        However...

                 Even Damian can make a mistake

        is by far the likeliest explanation.


;-)

Damian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.