Why does readln include the line terminator?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Apr 14 19:53:17 PDT 2009


Daniel Keep wrote:
> 
> 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.

And how about when sep is elaborate (e.g. regex)?

Andrei



More information about the Digitalmars-d mailing list