On 28.01.2010 21:59, Andrei Alexandrescu wrote:
How about this:

foreach (line; stdin.byLine()) { ... }

vs.

foreach (line; stdin.byLine) { ... }

How do I choose?


I'd say byLine as it's currently implemented in std.stdio is not a property. It initializes and returns a new ByLine struct each time it's called. It even has arguments that enables you to configure its return value differently each time you call it. Nowhere near how it would behave if it was a field.

A property should at least return the same value if you call it several times in a row, without doing anything in between that you'd expect to alter the value.

The fact that using byLine's return value changes the File itself doesn't change anything. That's a separate issue. Even if byLine was a field, using it would alter the underlying File.

Reply via email to