I think this could be accomodated for in the oft-unused Perl message-signature feature, which right now only takes basic types.
Apoc. 6 went through a total revamp of subroutines signatures. You can still use them like:
sub foo { my ($bar, $baz) = @_; . . . }
If you really want to, but if you did that, you'd be missing out on a lot of really cool stuff. I'm not so sure I personally want rigidly-enforced typing, but some of the signatures make calling conventions easier and make it obvious when we've called something incorrectly. At the same time, little flexibilty is lost over doing a complete check of @_ before we get to the actual code of the subroutine.
Type systems applied to objects is one way to solve the problem of $dog->bark vs. $tree->bark, but I'm not sure if it's the best. Delegation and Traits (both widely talked about in Perl6 development) are potentially much better.
My only OO heresy is that I despise "getter and setter" methods.
Hardly heresy. Having lots of accessors and mutators (i.e., methods which provide direct access to private data) is a sign of poor class design. I won't go as far to say that they should be absolutely forbidden. Whenever I enter such a debate, I hear this Drunken Scottish Object Programmer saying:
Ya can't just spread aaaccessors and muuutators all over your class design there ladie. You're screwwen the whole point!
But then again, maybe I should get the voices in my head checked out.
----
: () { :|:& };:
Note: All code is untested, unless otherwise stated
In reply to Re^3: perl6 & OO
by hardburn
in thread perl6 & OO
by chance
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |