www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - File.lockingBinaryWriter is not output range?

reply Denis Feklushkin <feklushkin.denis gmail.com> writes:
/+ 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.
Mar 19
next sibling parent reply Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
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 ().
Mar 19
parent reply Denis Feklushkin <feklushkin.denis gmail.com> writes:
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
Mar 19
parent Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
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.
Mar 19
prev sibling parent Denis Feklushkin <feklushkin.denis gmail.com> writes:
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?
Mar 19