On 3/24/15 4:38 PM, Dylan Knutson wrote:
immutable nfields = header.count('\t');
...
output.writeln(cycle("\t-").take(2 * nfields));

Super-win, now I only ever have to update the original column list.

Little things like this are what make me love D.

-Steve

I see that `take` returns a lazy range. That's really neat! How does
writeln handle the lazy range though? Standard way of dealing with
ranges in D, with calls to empty, front, and popFront (as in, does this
code allocate any temporaries at all with the GC?)

writeln uses format, which takes a dchar output range to send the result to. This in turn uses fputc on the stream (shudder). So no GC allocations are needed.

-Steve

Reply via email to