On 10/26/05, Luke Palmer <[EMAIL PROTECTED]> wrote:
[snip]
> Okay, an open class means you can add methods to it, right?  So, let's
> say you have this class:
>
>     class Foo {
>         method foo() {...}
>         method bar() {...}
>     }
>
> And this code:
>
>     my Foo $x = Foo.new;
>     $x.foo();
>     $x.bar();
>
> This might be compiled to the following pseudo intermediate code:
>
>     my $x = Foo[0]();
>     Foo[1]($x);
>     Foo[2]($x);
>
> Now let's say you extend the class:
>
>    class Foo is also {
>        method baz() {...}
>    }
>
> Is there any reason that the preceding pseudo intermediate code is no
> longer valid?  I don't see one; baz() is just installed in slot 3.  So
> why would you say it was faster to have it closed?

What about:

    class Foo is also {
        method foo() { ... }
    }

Where the second foo() is no longer what the first foo() did.
Furthermore, let's say you have:

    class Bar isa Foo {
        method floober() { ... }
    }

If they were roles, then role Bar could alias all the methods it
inherits from role Foo. In other words, it can cache all the method
lookups at compile-time. That's a substantial savings. If they're open
classes, the runtime has to throw out all the cached lookups the
moment any of the classes upstream are modified.

Plus, the argument is a straw man. Instead of:

    class Some::Class is also {
    }

you would do:

    class My::Version {
        does Some::Class;
    }

Problem solved.

Rob

Reply via email to