Re:Ask HN: Why hasn't Perl 6 taken off yet?
by Ulti on Monday November 07, 2016 @07:08AM
(#12890445)
If you come from only a Perl 5 background this is the issue. None of that is obvious. It is to someone who's seen OO languages that are a bit functional with good exception handling. In Perl 5 you would probably add to the top of the file:
use warnings;
use autodie;
To get similar functionality as the implicit Perl 6 IO error system.
If I had to guess, ‘foo.IO.words’ probably turns ‘foo’ into an IO object of some sort and then reads words. (Whether it reads the whole file into a string and splits that into words, or if it just reads the next word generator/iterator-style is not especially relevant.) An error throws an exception, like it would in Python or Ruby ‘open('dict.txt')’.
Also I kinda doubt that ‘loop over lines and split them into words’ is more readable than ‘.words’ which presumably does exactly what it says on the tin.
A word is probably defined by either \b or UAX #29. (And since IIRC one of the goals of Perl6 is good support for Unicode, \b hopefully uses the word boundary algorithm in that appendix.)