Why does readln include the line terminator?

Daniel Keep daniel.keep.lists at gmail.com
Tue Apr 14 19:50:09 PDT 2009



Andrei Alexandrescu wrote:
> ...
> 
> Right now readln preserves the separator. The newer File.byLine
> eliminates it by default and offers to keep it by calling
> File.byLine(KeepTerminator.yes). The allowed terminators are one
> character or a string. See
> 
> http://erdani.dreamhosters.com/d/web/phobos/std_stdio.html#byLine
> 
> I consider such an API adequate but insufficient; we need to add to it.
> 
> 
> Andrei

Why not:

char[] line, sep;
line = File.byLine();    // discard sep
line = File.byLine(sep); // pass sep out

The separator is likely to be more useful once extracted.

  -- Daniel



More information about the Digitalmars-d mailing list