Comment

Comment by PeCaN

…Just curious, have you ever used any of Perl(5), Python, or Ruby before?

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.)

parent PeCaN 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton