As the debate over revising the OO tutorials in the Perl 5 core continues, one point has come up as salient:
I am disappointed that after all this time we have no consensus on how to say in Perl "Class X has attribute Y" when so many other languages have solutions that have freed their users' minds up to move on to higher-level problems.
Fortunately, Jesse Vincent opened the door to a discussion of something other than what's appropriate in core documentation:
I'd love to see proposals (soon) for how we might do this in the core for 5.16 or 5.18. I'm not promising I'll accept one of them, but I'd love to see us actually discuss such a thing.
— Jesse Vincent, Re: Revising Perl's OO docs - a new OO tutorial
This is a great opportunity for armchair language designers to address a notable feature gap in core Perl 5. Here are a few constraints I think any design must address:
- New syntax is necessary, though it should be optional (as much as I dislike the idea of feature.pm, it hasn't yet been deprecated, so you might as well use it).
- New syntax should be as compatible both with Perl 6 and Moose as possible.
- New syntax can be simple (that is to say, there's no need for 5.16 or 5.18 to include a full type system such as Moose provides) but should allow for extension (it's okay not to support method signatures as long as it's possible to add them in the future).
- New syntax should allow enhancement with something like Method::Signatures.
- The new features should encourage programmers to do the right thing by default without forbidding them to do other things when necessary.
You can get by without creating a MOP, but the real power comes from doing something more than fields—if you can declare a class, declare attributes, and declare methods without having to
bless references or write your own constructor, accessors, and mutators, so much the better.