in reply to Re: Re: Foo::Button->new vs. newButton()
in thread Foo::Button->new vs. newButton()

Just because you dont inherit it, doesn't mean someone else wont want to.

-stvn
  • Comment on Re: Re: Re: Foo::Button->new vs. newButton()

Replies are listed 'Best First'.
Re: Re: Re: Re: Foo::Button->new vs. newButton()
by hhdave (Beadle) on Jan 16, 2004 at 20:21 UTC

    Incidentally, if you wanted to get that syntax elsewhere you could provide an autoload routine:-

    sub AUTOLOAD { my $f = $AUTOLOAD; $f=~s/.*:://; if ($f =~ /^new(.*)/) { return $1->new(@_); } else { die "Undefined subroutine: $f"; } }

    I don't think it's a very good idea though, and that wouldn't give you a Foo::Button, just a button. Probably not good at all :) You can do all sorts of interesting things with AUTOLOAD