On 3/13/2015 10:31 AM, Andrei Alexandrescu wrote:
For example the expression (assuming s is e.g. a string)File("/tmp/a").byChunk(4096).joiner.startsWith(s) opens a file, progressively reads chunks of 4KB, stitches them together at no cost, compares against a prefix until it makes a decision, then closes the file and returns the result. A putative Go user wouldn't even dream of using HasPrefix directly on a stream coming from a file; the whole endeavor would be a function that painstakingly takes all of these steps by hand. We need to take the "disconcerting" out the documentation equation while still exposing the power. s1.startsWith(s2) is perfectly apt for two strings, and that should be immediately apparent to someone who just needs that.
I suggest putting that snippet in the documentation as an example!
