Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let people clear the default value of an attribute when inheriting #176

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

skington
Copy link

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 value undef 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant