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

Re: package block syntax

Thread Previous | Thread Next
From:
Zefram
Date:
April 28, 2010 02:29
Subject:
Re: package block syntax
Message ID:
20100428092900.GC7385@lake.fysh.org
??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.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About