On 29.01.2010 05:20, Steven Schveighoffer wrote:
Andrei Alexandrescu Wrote:

 Michiel Helvensteijn wrote:
 >  Andrei Alexandrescu wrote:
 >
 >>>>  foreach (line; stdin.byLine()) { ... }
 >>>>
 >>>>  vs.
 >>>>
 >>>>  foreach (line; stdin.byLine) { ... }
 >>>>
 >>>>  How do I choose?
 >>>  byLine is a property.  It is fetching a range on stdin.
 >>>
 >>>  -Steve
 >>  Damn. I was sure the answer will be different.
 >
 >  byLine() is a function. It changes the state of stdin. Calling it
 >  consecutively will in general result in different return values. If there
 >  were two guys: stdin.currentLine (property) and stdin.nextLine(), it would
 >  be a different story.

No no no.  byLine returns a struct, it does not modify stdin.  Operating on the 
struct modifies stdin, but that is outside the call to the property getter.

Look at it this way (although this is not the only way to look at it), could 
byLine be a field inside stdin?  It could.  You could store a copy of what 
byLine returns inside stdin, and people could just access it.

Before more time is wasted in this discussion, I would like to point out that byLine does actually have two arguments. I wrote a post about byLine yesterday, but noone seems to have noticed..

Reply via email to