On Fri, Oct 03, 2008 at 07:22:28PM -0700, [EMAIL PROTECTED] wrote:
> Log:
> [rakudo] implement 'package' package declarator
> 
> Modified: trunk/languages/perl6/perl6.pir
> ==============================================================================
> --- trunk/languages/perl6/perl6.pir   (original)
> +++ trunk/languages/perl6/perl6.pir   Fri Oct  3 19:22:26 2008
> @@ -1434,15 +1472,32 @@
>          my $past := $( $/{$key} );
>  
>          # Restore outer package.
> -        $?PACKAGE := @?PACKAGE.shift();
> -        if $<sym> eq 'class' {
> -            $?CLASS := @?CLASS.shift();
> +        if    $<sym> eq 'package' {
> +            $?PACKAGE := @?PACKAGE.shift();
>          }
> +        ##  module isa package
> +        elsif $<sym> eq 'module' {
> +            $?MODULE  := @?MODULE.shift();
> +            $?PACKAGE := @?PACKAGE.shift();
> +        }
> [...]


These look wrong to me -- wouldn't they result in $?PACKAGE, $?MODULE,
etc. being set to the package, module, etc. that we're just exiting?

At any rate, S02 is fairly clear that $?BLOCK is always the 
same as @?BLOCK[0], and I'm pretty sure the code above violates
that (unless things are being reset somewhere later in the code
that I'm unaware of).

At any rate, all of this can be made *much* shorter if at the
end of the method we simply have:

    $?PACKAGE := @?PACKAGE[0];
    $?MODULE  := @?MODULE[0];
    $?CLASS   := @?CLASS[0];

and let the (simulated) switch statements above simply 
manipulate the @?FOO arrays.

Pm

Reply via email to