develooper Front page | perl.perl5.porters | Postings from April 2010

Re: package block syntax

Thread Previous | Thread Next
April 28, 2010 02:29
Re: package block syntax
Message ID:
??var Arnfj??r?? Bjarmason wrote:
>    goto label;
>    {
>        label: package Boo;
>        print 'moo';
>    }

Curious.  That's actually invalid: a package declaration isn't syntactically
allowed to have a label.  But this is an existing bug in B::Deparse:

	$ perl -MO=Deparse -e 'goto label; { package Boo; label: print "moo"; }'

produces the same output.  B::Deparse needs to be taught that when
a nextstate op has both a label and a change of package the package
declaration needs to be emitted first.

I suggest you check out the B::Concise output to check the equivalence
of the op tree.

>It also looks like Deparse hasn't been updated to work package PACKAGE
>VERSION for either the new syntax or the old:

It can't show the version.  The version part of a package declaration is
processed at compile time, directly modifying the package and leaving no
trace in the op tree.  B::Deparse is correct in not showing any form of
assignment to $Foo::VERSION, because no such assignment was ever compiled.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About