zoffixznet / IOwesomeness

1 stars 0 forks source link

AP: Make &words default to $*ARGFILES #8

Open zoffixznet opened 7 years ago

AlexDaniel commented 7 years ago

I'm also wondering how far should we go with this. For example, should chars also do the same thing, or is it for some reason unrelated to the list?

And also… wouldn't it be more useful if words did something like get.words instead of slurp.words? I'm just thinking how many times I actually needed to get all words and not just the ones from the current line. Hm, I don't know.

zoffixznet commented 7 years ago

I don't see chars as related. It's a method on a Str that gives info about that Str, while the rest in question are about getting Strs (from a handle)

It's not .slurp.words but just .words, as in the file doesn't get read entirely before you can get the first word. If you want to work just with the current line, then you're asking for chunking by lines, not by words; and the fact that you want to process that line by words is another layer on top of that.

All of the methods in question all map directly to IO::Handle's methods, so IMO making words exceptional in this case to save 4 characters of typing would do more damage than good.

The way I envision slurp, lines, words, and comb are just a way to structure the stream of data from a handle (with &get being an outlier that I might've not added if this were designed from scratch and just used &prompt with empty message). So refining that structure with another layer feels off. A parallel would be "a b\nc".words returning ("a", "b"), which is confusing.

AlexDaniel commented 7 years ago

Right. That makes sense.