This question came out of a joking comment on IRC, but it's a serious
concern. Can chained buts be optimized, or must the compiler strictly
create intermediate metaclasses, classes and objects in the following:

        my $a = $b but C but D but E but F;

The difference is between:

        my $tmprole = role {
                is $b.meta.role;
                does C;
                does D;
                does E;
                does F;
        };
        my $a = $b but $tmprole;

and

        my $tmpbc = $b but C;
        my $tmpbcd = $tmpbc but D;
        my $tmpbcde = $tmpbcd but E;
        my $a = $tmpbcde but F;

In the second example, constructors are called 4 times, but in the first
case constructors are called only once.... sort of. Until you get to
taking about constructors on the metaclasses, but metaclass constructors
still make my head hurt.

The same goes for destructors, but I don't think those get to get called
until everything goes away (since there's a reference chain between
them).

-- 
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback


Reply via email to