On Sat, Oct 4, 2008 at 8:01 AM, Patrick R. Michaud <[EMAIL PROTECTED]> wrote:
> 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.
>
i must admit, i didn't spend much time analyzing the existing code. i
refactored the switch and added $?PACKAGE and @?PACKAGE to match the
existing logic. spectest_regression all passed. this must all be
untested, as the ? twigil is not yet implemented.

i'll take a closer look at it when i get a chance. it may mean i'll be
implementing the ? twigil in the process.

my ultimate goal is the 'is export()' trait, so i've been doing just
enough to get that working quickly. so far, that has involved adding -
and ' to identifiers, adding $?PACKAGE, and now the ? twigil *sigh*.

i promise i'll clean up after myself as soon as i get my main goal completed.
~jerry

Reply via email to