in reply to Re: Extending a class
in thread Extending a class

Thank you for your reply! However, isn't SVG::new() already in place anyway? The MyPackage object builds and yields a MyPackage-blessed object as revealed by Data::Dumper.

I'm checking the book by the way!

Replies are listed 'Best First'.
Re^3: Extending a class
by Anonymous Monk on Apr 13, 2016 at 17:14 UTC

    However, isn't SVG::new() already in place anyway? The MyPackage object builds and yields a MyPackage-blessed object as revealed by Data::Dumper.

    :) ok, if the constructor is creating a MyPackage, then which code is creating a SVG::Element?

    Think a bout it

      $self->group(...) in Bar() does. I was expecting the group() method to be inherited by MyPackage and the SVG:: class blessing of the resulting object to be overridden by MyPackage:: class... but that was too much of an expectation as it turns out to be. Still have to know if it's Perl's quirky OO-system or my plain OO-ignorance.

        It works pretty much the same in all OO languages, just because you make a class Bar that is a subclass of Foo, doesn't mean Foo->yada creates Bar objects, Foo->yada does what it did before

        If the original class is not meant to be subclassed, and you want to subclass it, you'll have a lot of work ahead of youand you want to sub

        Modern Perl discusses "Redispatching Methods in AUTOLOAD"

        but from what I can guess of your question, you don't need subclass or redispatch