Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 86939
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: MAUKE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.002000
Fixed in: 1.004000



Subject: 'extends' sometimes tries to load modules
The documentation for 'extends' says: | extends 'Parent::Class'; | | Declares base class. Multiple superclasses can be passed for multiple | inheritance (but please use roles instead). | | Calling extends more than once will REPLACE your superclasses, not add to | them like 'use base' would. What it doesn't say: In addition to setting up inheritance, in some cases[1] it tries to load 'Parent/Class.pm' from disk first. I find this behavior surprising and it doesn't seem to be documented anywhere. I think this behavior should be documented (or alternatively removed). [1] exact logic hard to describe; see sub _load_module in Moo::_Utils
Subject: Re: [rt.cpan.org #86939] 'extends' sometimes tries to load modules
Date: Mon, 15 Jul 2013 10:29:45 -0700
To: Lukas Mai via RT <bug-Moo [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Mon, Jul 15, 2013 at 06:03:23AM -0400, Lukas Mai via RT wrote: Show quoted text
> What it doesn't say: In addition to setting up inheritance, in some cases[1] it > tries to load 'Parent/Class.pm' from disk first. I find this behavior > surprising and it doesn't seem to be documented anywhere. > > I think this behavior should be documented (or alternatively removed).
It can certainly be documented. I'm not sure why it should be confusing though, as 'use parent' and 'use base' also load the module first if it isn't already in %INC.
The heuristic it uses is different from what both base and parent do though, so it's probably worth mentioning.
On Mon Jul 15 13:29:57 2013, ETHER wrote: Show quoted text
> On Mon, Jul 15, 2013 at 06:03:23AM -0400, Lukas Mai via RT wrote:
> > What it doesn't say: In addition to setting up inheritance, in some
> cases[1] it
> > tries to load 'Parent/Class.pm' from disk first. I find this
> behavior
> > surprising and it doesn't seem to be documented anywhere. > > > > I think this behavior should be documented (or alternatively
> removed). > > It can certainly be documented. I'm not sure why it should be > confusing > though, as 'use parent' and 'use base' also load the module first if > it > isn't already in %INC.
It's confusing because 'extends' is not described as being like base/parent; it's described as declaring base classes, which I understand to be like '@ISA = ...'. The documentation for base/parent says: "Allows you to both load one or more modules, while setting up inheritance from those modules at the same time." ... i.e. it emphasizes the module loading part that 'extends' doesn't even mention.
The behavior of this has been changed somewhat. It now always tries to load extends/with modules, but still continues without error if the module doesn't exist but its stash has subs. The documentation has been updated to reflect this.
Resolved in 1.004000.