D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7635 - Inconsistent naming in std.stdio - byLine(), byChunk()
Summary: Inconsistent naming in std.stdio - byLine(), byChunk()
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-03 10:18 UTC by Sandeep Datta
Modified: 2012-03-03 12:03 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Sandeep Datta 2012-03-03 10:18:23 UTC
The nomenclature adopted for some std.stdio methods like byLine and byChunk is inconsistent with preestablished conventions where functions/properties returning a collection of entities is named using the plural form of said entity. Following convention reduces the cognitive load on developers significantly in the long run.

In view of the above IMHO byLine() and byChunk(size_t) should be renamed to lines() and chunks(size_t) respectively.

Also the struct ByLines should be renamed to something like LineReader (let's avoid the plural form LinesReader here since presumably the LineReader reads one line at a time). Also convention dictates that class names should be nouns. English is not my first language but IMO "by lines" is neither a noun nor a noun phrase (or gerund for that matter).

It seems the by*() names facilitate fluent reading of the foreach construct but as the following code snippet shows the fluency is not lost by using the suggested names...

//Read: for each line in stdin.lines() do ...
foreach(line; stdin.lines(){
    ...do something with line...
}
Comment 1 Walter Bright 2012-03-03 12:03:43 UTC
Renaming these things breaks existing code. There's got to be a pretty high value to justify such breakage, and I don't think this case is justified.