Why I'm Excited about D
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 8 11:11:48 PDT 2015
On 4/8/2015 10:33 AM, Adam D. Ruppe wrote:
> On Wednesday, 8 April 2015 at 17:17:21 UTC, Walter Bright wrote:
>> writeln is an OutputRange.
>
> No, it isn't. It isn't even remotely close to one - an OutputRange is a type,
I meant an instance of a type, as in:
i is an int
meaning i has type int.
> writeln is a function. isOutputRange doesn't even return false for it, it
> outright fails to compile!
I understand that a true OutputRange would require one to write:
arg.copy(writeln);
and that a common idiom is to write it so the copy() can be implicit. I haven't
made up my mind as to the right style here.
> File isn't an output range either btw. An output range is defined by the
> presence of a put method, which File doesn't have.
>
> b.d(4): Error: static assert (isOutputRange!(File, char)) is false
>
>
> Even putting aside the formal definition of output range, output is NOT part of
> the pipeline! Pipelines can be composed and they keep pumping data through them.
An output range is the caboose of a pipeline (to mix metaphors).
> writeln does not transform its input nor does it forward it to the next item in
> the pipe. It just eats it.
It places its input into a container.
> That's totally different than everything else in the sequence. And that's not
> even bringing in writeln's sister function, writefln, whose first argument isn't
> what is to be printed at all!
It's true that a lot of Phobos code was designed pre-ranges, and the parameters
aren't set up ideally for it. I've been doing some work to fix that.
More information about the Digitalmars-d
mailing list