Good name for f.byLine.map!(x => x.idup)?
monarch_dodra
monarchdodra at gmail.com
Thu Mar 20 00:55:43 PDT 2014
On Thursday, 20 March 2014 at 01:38:38 UTC, Andrei Alexandrescu
wrote:
> On 3/19/14, 4:53 PM, Meta wrote:
>> On Wednesday, 19 March 2014 at 22:30:55 UTC, Peter Alexander
>> wrote:
>>> On Sunday, 16 March 2014 at 16:58:36 UTC, Andrei Alexandrescu
>>> wrote:
>>>> A classic idiom for reading lines and keeping them is
>>>> f.byLine.map!(x
>>>> => x.idup) to get strings instead of the buffer etc.
>>>
>>> f.readLines
>>
>> What about a simpler f.iter() or f.lineIter()?
>
> Ideally it would be a variation of byLine. -- Andrei
What about simply templatizing (*) it?
byLine() => implicit char[]
byLine!string() => dupes
This has the double advantage that:
* Does not introduce a new symbol
* Can be customized for wchar/dchar
In particular, the wchar thing could be of interest to those that
are reading a file they now is UTF16/UCS2.
(*) Technically, it's already a template, but the parameters are
inferred. We could make it so that we can use explicitly defined
parameters. In particular, so that the output type is specified
before the terminator type. AFAIK, the transition can be made
seemlessly with no breakage.
More information about the Digitalmars-d
mailing list