Re: BUILD called twice.

[email protected] (Karen Etheridge)
Newsgroups perl.moose
Message-ID <[email protected]>
On Thu, Feb 14, 2013 at 12:05:02PM -0600, Dave Rolsky wrote:
> This is definitely a bug but it might be tricky to fix. Basically, method 
> modifiers effectively copy the modified sub into the class that has the 
> modifier. Moose then sees a BUILD in the subclass and baseclass and 
> dutifully calls both.
> 
> But as you point out, what you did is just wrong anyway. The whole point 
> of BUILD is that defining it in subclasses doesn't hide the parent's 
> implementation.
> 
> The only time you need modifiers on BUILD is when you want a role to 
> modify BUILD.

Would it be sensible to warn in this case - when the BUILD sub is copied
from the base class into the subclass to be modified?  That would force the
user to create an empty BUILD first before modifying it.  I can't think of
a case where this behaviour is actually intentionally wanted.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.