Let people clear the default value of an attribute when inheriting #176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When attempting to fix MooseX::LazyRequire so you can turn it on and off in a sub-class, I came up against the problem that when you inherit from a parent class's attribute, you can't delete an existing key; you can only replace it.
And no, replacing an existing default value with
undef
isn't the same as there being no default, in the same way that any Moose object's attribute having the explicit valueundef
is different from it not having a value at all. I remember seeing documentation that claimed that somewhere, but unfortunately I haven't been able to track that down since I realised its mistake.I appreciate that the note to contributors says (I paraphrase) "we won't add any new features; please consider a MooseX module instead". I tried going down the MooseX route when patching MooseX::LazyRequire, but the problem seems to be a bit too deep in the guts of Moose for that?
I've tried to adhere to existing standards when it comes to exceptions, but I'll confess I haven't gone through every single exception in detail. Similarly, I've tried to match the coding style, but this is a new codebase to me so I'm sure there are things I've missed.
I haven't considered which other attributes of an attribute you might want to clear like this, on top of default. I don't even know if there are any attributes like default, where you have a tripartite value of defined / undefined / non-existent. OTOH, it's a commonplace that the best software is that which is used for a purpose that its authors didn't intend.