Thread overview
File.lockingBinaryWriter is not output range?
Mar 19, 2019
Denis Feklushkin
Mar 19, 2019
Vladimir Panteleev
Mar 19, 2019
Denis Feklushkin
Mar 19, 2019
Vladimir Panteleev
Mar 19, 2019
Denis Feklushkin
March 19, 2019
/+ dub.sdl:
name "hello_world"
+/

import std.algorithm, std.range, std.stdio;

void main()
{
    // lockingBinaryWriter: Returns an output range that locks the file and allows fast writing to it.
    // https://dlang.org/library/std/stdio/file.locking_binary_writer.html

    stdout.lockingBinaryWriter.put(cast(byte) 123); // works

    // But this assert is false:
    static assert(isOutputRange!(typeof(stdout.lockingBinaryWriter), byte));
}

This blocks to user File as Stream for msgpack-d.

March 19, 2019
On Tuesday, 19 March 2019 at 13:14:52 UTC, Denis Feklushkin wrote:
> /+ dub.sdl:
> name "hello_world"
> +/

This doesn't seem necessary :)

> static assert(isOutputRange!(typeof(stdout.lockingBinaryWriter), byte));

static assert(isOutputRange!(typeof(stdout.lockingBinaryWriter()), byte));

typeof(stdout.lockingBinaryWriter) is a function type. You need the ().

March 19, 2019
On Tuesday, 19 March 2019 at 13:14:52 UTC, Denis Feklushkin wrote:

>     stdout.lockingBinaryWriter.put(cast(byte) 123); // works
>
>     // But this assert is false:
>     static assert(isOutputRange!(typeof(stdout.lockingBinaryWriter), byte));
> }

Looks like isOutputRange is not checks "put" method properly?

March 19, 2019
On Tuesday, 19 March 2019 at 13:20:37 UTC, Vladimir Panteleev wrote:
> On Tuesday, 19 March 2019 at 13:14:52 UTC, Denis Feklushkin wrote:
>> /+ dub.sdl:
>> name "hello_world"
>> +/
>
> This doesn't seem necessary :)

I add it ~everywhere for faster reproducing of cases.

>
>> static assert(isOutputRange!(typeof(stdout.lockingBinaryWriter), byte));
>
> static assert(isOutputRange!(typeof(stdout.lockingBinaryWriter()), byte));
>
> typeof(stdout.lockingBinaryWriter) is a function type. You need the ().

Ooops! Thanks! :-)

/thread
March 19, 2019
On Tuesday, 19 March 2019 at 13:25:27 UTC, Denis Feklushkin wrote:
> On Tuesday, 19 March 2019 at 13:20:37 UTC, Vladimir Panteleev wrote:
>> On Tuesday, 19 March 2019 at 13:14:52 UTC, Denis Feklushkin wrote:
>>> /+ dub.sdl:
>>> name "hello_world"
>>> +/
>>
>> This doesn't seem necessary :)
>
> I add it ~everywhere for faster reproducing of cases.

Not sure what you mean by this, because 1) it's not even doing anything if there are no dependencies on Dub packages, and 2) test cases should be self-contained and not have external dependencies anyway. If the test case can only be reproduced with some compiler switches, a shebang using rdmd (with --shebang for multiple switches) can be used to illustrate it.