|We don't bite newbies here... much|
Re^2: Mini HowTo: How to port Perl 5 modules to Perl 6by iblech (Friar)
|on Mar 25, 2005 at 21:29 UTC||Need Help??|
The old grep/map/sort chain works unmodified, too, I just wanted to demonstrate the new pipeline operators. Actually, there are even some other ways too:
The accessors are especially useful for subclassing:
Now, you may ask, "why is that useful?" -- In Perl 5, when one changed the internal representation of some data in the superclass, but fixed the public accessor methods so they translate between the old representation the user expects and the new one used internally, everything was fine. Except, when there was some subclass: The subclass would still directly access the internal representation, which would, of course, not work.
Now, with Perl 6, one may subclass freely without having to fear that internal changes of the superclass will affect the subclass. :)
Generally, the Perl 5 way works in Perl 6, too. But the new ways Perl 6 gives you are often shorter/clearer/more consice/more elegant/more efficient/whatever.