Only by convention. Conventions can be changed.
To an extent, Moose has already changed that convention. The new method generated by Moose can be a little inflexible, so many people write a wrapper constructor around it — new_from_foo or new_with_bar or whatever — and document that this should be used rather than calling new directly.
| [reply] [d/l] [select] |
That gradual change is something I'm not completely happy with - only I fail to come up with a better solution.
Moose did change the convention only a bit: It offers its own new with a key/value API, but also has BUILDARGS and other magic like coercions which allow to mimic practically any existing constructor API. Corinna will not provide the same helpers for backward compatibility. I guess I can live with that, because during the last decade or so I adopted the key/value style anyway.
The "bless vs. new" thing has hit me a lot harder in situations where serialization of objects is needed. Even complex Moose objects can be built from e.g. JSON or YAML strings, and then blessed into the appropriate class. This is no longer possible with Object::Pad or Corinna: You can (re)create their objects only by calling new, undergoing the same API restrictions and validations as for fresh objects. If an object, during its lifetime, achieves a state which is not available by calling new, then... object persistence gets a lot harder.
| [reply] |
| [reply] [d/l] [select] |