Re: DUB dependency issue
On Wednesday, 4 October 2017 at 01:59:48 UTC, Andrew Edwards wrote: Attempting to use iopipe but not sure what I'm doing incorrectly Finally figured it out. For some reason, the init find the local dependency to load but simply adding it to the dub.json afterward resolves the issue.
Re: Vibe.d using Windows Certificate binding, possible?
On 04/10/2017 3:54 AM, Jesse Phillips wrote: On Tuesday, 3 October 2017 at 23:29:49 UTC, rikki cattermole wrote: On 03/10/2017 4:52 PM, Jesse Phillips wrote: I'm pretty sure this isn't possible, but maybe someone understands Windows better. Windows provides a means no bind a certificate to a port using netsh.exe. This means (at least for standard Windows networking calls) connections to that port will be given the bound cert. The Vibe.d documents state that a Certificate chain and key needs to be provided. I'm pretty sure that the port binding requires very specific Network API calls, possible .NET only. Can any confirm or deny? Perhaps you could reference the command (aka the args with an example)? Otherwise, its a lot harder to figure out what it is doing under the hood. Here is the command docs https://msdn.microsoft.com/en-us/library/windows/desktop/cc307220(v=vs.85).aspx "Application program source files include the Http.h header file to access function prototypes and structure definitions for the HTTP Server API. Developers can use the Httpapi.lib library file to build applications that use the HTTP Server API. At runtime, applications link to the Httpapi.dll." So no, vibe.d can't work with it. This a special snow flake feature from 2k3 server days.
Re: Vibe.d using Windows Certificate binding, possible?
On Tuesday, 3 October 2017 at 23:29:49 UTC, rikki cattermole wrote: On 03/10/2017 4:52 PM, Jesse Phillips wrote: I'm pretty sure this isn't possible, but maybe someone understands Windows better. Windows provides a means no bind a certificate to a port using netsh.exe. This means (at least for standard Windows networking calls) connections to that port will be given the bound cert. The Vibe.d documents state that a Certificate chain and key needs to be provided. I'm pretty sure that the port binding requires very specific Network API calls, possible .NET only. Can any confirm or deny? Perhaps you could reference the command (aka the args with an example)? Otherwise, its a lot harder to figure out what it is doing under the hood. Here is the command docs https://msdn.microsoft.com/en-us/library/windows/desktop/cc307220(v=vs.85).aspx
Re: Should this Compile?
On Tuesday, 3 October 2017 at 23:13:00 UTC, Jonathan M Davis wrote: On Tuesday, October 03, 2017 22:42:35 SamwiseFilmore via Digitalmars-d-learn wrote: On Tuesday, 3 October 2017 at 22:37:17 UTC, SamwiseFilmore wrote: > Am I using the ternary operator correctly here, or is this > an issue with dmd? I'm using dmd v2.076.0. I wrapped the ternary in parentheses, and it compiled. Still, I'm wondering about this behavior. Operator precedence makes it quite clear how the ternary operator is supposed to function, and if you're ever not sure, then put parens around it. https://wiki.dlang.org/Operator_precedence - Jonathan M Davis Thanks, that clears things up. I appreciate it!
DUB dependency issue
Attempting to use iopipe but not sure what I'm doing incorrectly I've cloned the repository in /Users/edwarac/git.repo.dir/ then added the path to dub: edwarac-pc:.dub edwarac$ dub add-path /Users/edwarac/git.repo.dir edwarac-pc:.dub edwarac$ dub list Packages present in the system and known to dub: iopipe ~master: /Users/edwarac/git.repo.dir/iopipe/ iopipe:byline ~master: /Users/edwarac/git.repo.dir/iopipe/ iopipe:convert ~master: /Users/edwarac/git.repo.dir/iopipe/ iopipe:unzip ~master: /Users/edwarac/git.repo.dir/iopipe/ iopipe:zip ~master: /Users/edwarac/git.repo.dir/iopipe/ Now I'm trying to init a project with iopipe as a dependency but am receiving the following error: Package recipe format (sdl/json) [json]: Name [syosetsu]: Description [A minimal D application.]: Author name [edwarac]: License [proprietary]: Copyright string [Copyright © 2017, edwarac]: Add dependency (leave empty to skip) []: requests Added dependency requests ~>0.5.3 Add dependency (leave empty to skip) []: iopipe Could not find package 'iopipe'.
Re: Vibe.d using Windows Certificate binding, possible?
On 03/10/2017 4:52 PM, Jesse Phillips wrote: I'm pretty sure this isn't possible, but maybe someone understands Windows better. Windows provides a means no bind a certificate to a port using netsh.exe. This means (at least for standard Windows networking calls) connections to that port will be given the bound cert. The Vibe.d documents state that a Certificate chain and key needs to be provided. I'm pretty sure that the port binding requires very specific Network API calls, possible .NET only. Can any confirm or deny? Perhaps you could reference the command (aka the args with an example)? Otherwise, its a lot harder to figure out what it is doing under the hood.
Re: Should this Compile?
On Tuesday, October 03, 2017 22:42:35 SamwiseFilmore via Digitalmars-d-learn wrote: > On Tuesday, 3 October 2017 at 22:37:17 UTC, SamwiseFilmore wrote: > > Am I using the ternary operator correctly here, or is this an > > issue with dmd? I'm using dmd v2.076.0. > > I wrapped the ternary in parentheses, and it compiled. Still, I'm > wondering about this behavior. Operator precedence makes it quite clear how the ternary operator is supposed to function, and if you're ever not sure, then put parens around it. Almost every operator has higher precedence than the ternary operator, so aside from simple assignments, you typically have to use parens around it. For some reason, a lot of folks seem to assume that the ternary operator has much higher precedence than it does and get confused by the result, but if you just look at the operator precedence table, it should be pretty obvious why you're seeing what you're seeing: https://wiki.dlang.org/Operator_precedence - Jonathan M Davis
Re: Should this Compile?
On Tue, Oct 03, 2017 at 10:37:17PM +, SamwiseFilmore via Digitalmars-d-learn wrote: [...] > string toString() { > return > this.value.toString() ~ > " of " ~ > this.suit.toString() ~ > this.suit == CardSuit.diamonds ? "" : "\t" ~ > "\tfacing " ~ > this.facing.toString(); > } [...] > This code does not compile with this error message: Error: > incompatible types for ((toString(this.p_value) ~ " of " ~ > toString(this.p_suit)) ~ (this.p_suit)): 'string' and 'CardSuit' > > Am I using the ternary operator correctly here, or is this an issue > with dmd? I'm using dmd v2.076.0. When in doubt, always parenthesize around the ?: operator to prevent ambiguities. I'd write that line as: ... ~ ((this.suit == CardSuit.diamonds) ? "" : "\t") ~ ... It's a few characters more, but will save you headaches from obscure errors caused by unexpected operator precedences. T -- A linguistics professor was lecturing to his class one day. "In English," he said, "A double negative forms a positive. In some languages, though, such as Russian, a double negative is still a negative. However, there is no language wherein a double positive can form a negative." A voice from the back of the room piped up, "Yeah, yeah."
Re: Should this Compile?
On Tuesday, 3 October 2017 at 22:37:17 UTC, SamwiseFilmore wrote: Am I using the ternary operator correctly here, or is this an issue with dmd? I'm using dmd v2.076.0. I wrapped the ternary in parentheses, and it compiled. Still, I'm wondering about this behavior.
Should this Compile?
I've created toString() for a struct (which is a lot more complicated than what I've provided here) that returns a large number of concatenated strings. Here is the example: struct Card { // Flesh out these enums appropriately CardSuit suit; CardValue value; Facing facing; string toString() { return this.value.toString() ~ " of " ~ this.suit.toString() ~ this.suit == CardSuit.diamonds ? "" : "\t" ~ "\tfacing " ~ this.facing.toString(); } } This code does not compile with this error message: Error: incompatible types for ((toString(this.p_value) ~ " of " ~ toString(this.p_suit)) ~ (this.p_suit)): 'string' and 'CardSuit' Am I using the ternary operator correctly here, or is this an issue with dmd? I'm using dmd v2.076.0. This is the ideal way to implement this function, although I could do it other ways.
Re: non-block reading from pipe stdout
On Tuesday, 3 October 2017 at 12:32:43 UTC, kdevel wrote: IMHO a program should sleep (consume 0 CPU time and 0 energy) if there is nothing to process. This is best accomplished by not polling on a file descriptor in order to check if data has arrived. If your program must yield() there's probably something wrong with the design. I would suggest you put all the filedescriptors into a fd_set an then select(3) on the set. Programs based on fibers can't sleep while wait data and it's not a design problem.
For fun: Expressive C++ 17 Coding Challenge in D
Found on Reddit: https://www.reddit.com/r/programming/comments/740617/the_expressive_c17_coding_challenge/ How would you do it in D? Ali P.S. You can ignore the following note from the challenge text; I don't think it applies to D. Honestly, I don't think it matters for C++17 either. :) "You can assume input files won't be super large and can fit fully into memory."
Re: Is there further documentation of core.atomic.MemoryOrder?
Thank you. For anyone else with the same question, I also found this page helpful: http://en.cppreference.com/w/cpp/atomic/memory_order
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
On Tuesday, 3 October 2017 at 15:52:52 UTC, sighoya wrote: On Tuesday, 3 October 2017 at 15:30:52 UTC, Daniel Kozak wrote: writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); Dne 3. 10. 2017 3:55 odpoledne napsal uživatel "sighoya via Digitalmars-d-learn" : But when I write this to: writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); it complains by: test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(17): Error: template instance test.bar!(Bar, Foo, int) error instantiating I still get test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(18): Error: template instance test.bar!(Bar, Foo, int) error instantiating by struct Foo(T) { T value; } struct Bar (R,S) { R!S fooint; } //T!S foo(S, alias T)(T!S v) { return v; } T!(S!R) bar(alias T,alias S,R)(T!(S!R) v) {return v;} void main() { import std.stdio; //writeln(foo!(int, Foo)(Foo!int(1))); //writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); } Thanks!!!
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
https://run.dlang.io/is/oqbYNb On Tue, Oct 3, 2017 at 5:52 PM, sighoya via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 3 October 2017 at 15:30:52 UTC, Daniel Kozak wrote: > >> writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); >> >> Dne 3. 10. 2017 3:55 odpoledne napsal uživatel "sighoya via >> Digitalmars-d-learn" : >> >> But when I write this to: >> >> writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); >> >> it complains by: >> >> test.d(11): Error: template instance T!(S!int) does not match template >> declaration Bar(R, S) >> test.d(11): Error: template instance T!(S!int) does not match template >> declaration Bar(R, S) >> test.d(17): Error: template instance test.bar!(Bar, Foo, int) error >> instantiating >> > > I still get > > test.d(11): Error: template instance T!(S!int) does not match template > declaration Bar(R, S) > test.d(11): Error: template instance T!(S!int) does not match template > declaration Bar(R, S) > test.d(18): Error: template instance test.bar!(Bar, Foo, int) error > instantiating > > > by > > struct Foo(T) { > T value; > } > > struct Bar (R,S) { > R!S fooint; > } > > > //T!S foo(S, alias T)(T!S v) { return v; } > T!(S!R) bar(alias T,alias S,R)(T!(S!R) v) {return v;} > > > void main() { > import std.stdio; > //writeln(foo!(int, Foo)(Foo!int(1))); > //writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); > writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); > } > > >
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
On Tuesday, 3 October 2017 at 15:30:52 UTC, Daniel Kozak wrote: writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); Dne 3. 10. 2017 3:55 odpoledne napsal uživatel "sighoya via Digitalmars-d-learn" : But when I write this to: writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); it complains by: test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(17): Error: template instance test.bar!(Bar, Foo, int) error instantiating I still get test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(18): Error: template instance test.bar!(Bar, Foo, int) error instantiating by struct Foo(T) { T value; } struct Bar (R,S) { R!S fooint; } //T!S foo(S, alias T)(T!S v) { return v; } T!(S!R) bar(alias T,alias S,R)(T!(S!R) v) {return v;} void main() { import std.stdio; //writeln(foo!(int, Foo)(Foo!int(1))); //writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); }
Vibe.d using Windows Certificate binding, possible?
I'm pretty sure this isn't possible, but maybe someone understands Windows better. Windows provides a means no bind a certificate to a port using netsh.exe. This means (at least for standard Windows networking calls) connections to that port will be given the bound cert. The Vibe.d documents state that a Certificate chain and key needs to be provided. I'm pretty sure that the port binding requires very specific Network API calls, possible .NET only. Can any confirm or deny?
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)())); Dne 3. 10. 2017 3:55 odpoledne napsal uživatel "sighoya via Digitalmars-d-learn" : But when I write this to: writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); it complains by: test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(17): Error: template instance test.bar!(Bar, Foo, int) error instantiating
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
But when I write this to: writeln(bar!(Bar,Foo,int)(Bar!(Foo,int))); it complains by: test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(11): Error: template instance T!(S!int) does not match template declaration Bar(R, S) test.d(17): Error: template instance test.bar!(Bar, Foo, int) error instantiating
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
On Tuesday, 3 October 2017 at 13:31:00 UTC, sighoya wrote: struct Bar (R,S) { T!(S!R) bar(alias T,alias S,R)(T!(S!R) v) {return v;} Bar takes two arguments, but here you are only passing one. Keep in mind that T!(...) is Bar. You called T!(S!(R)) when it was actually written to accept T!(S, R) It might help to forget about the ! and just think of regular functions. Bar(R, S); is the definition but inside you called T(S(R)) when it expected T(S, R)
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
Thanks, How do I construct such a type. I don't get it done right with: struct Foo(T) { T value; } struct Bar (R,S) { R!S fooint; } T!(S!R) bar(alias T,alias S,R)(T!(S!R) v) {return v;} void main() { import std.stdio; writeln(bar!(Bar,Foo,int)(Bar!(Foo!int(1.0; }
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
On Tuesday, 3 October 2017 at 12:58:47 UTC, sighoya wrote: On Tuesday, 3 October 2017 at 12:09:04 UTC, rikki cattermole wrote: On 03/10/2017 1:05 PM, sighoya wrote: Especially, I mean something like T foo(S,T)(T i) { ... } struct Foo(T) { T value; } T!S foo(S, alias T)(T!S v) { return v; } void main() { import std.stdio; writeln(foo!(int, Foo)(Foo!int(1))); } Cool, but it seems that only a nesting of two is allowed, right? This one gives an error: T!S!R bar(alias T,alias S,R)(T!S!R v) {return v;} Error: multiple ! arguments are not allowed That is because you have to wrap multiple with (). Use T!(S!R) instead.
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
On Tuesday, 3 October 2017 at 12:09:04 UTC, rikki cattermole wrote: On 03/10/2017 1:05 PM, sighoya wrote: Especially, I mean something like T foo(S,T)(T i) { ... } struct Foo(T) { T value; } T!S foo(S, alias T)(T!S v) { return v; } void main() { import std.stdio; writeln(foo!(int, Foo)(Foo!int(1))); } Cool, but it seems that only a nesting of two is allowed, right? This one gives an error: T!S!R bar(alias T,alias S,R)(T!S!R v) {return v;} Error: multiple ! arguments are not allowed
Re: non-block reading from pipe stdout
On Tuesday, 3 October 2017 at 12:20:09 UTC, Oleg B wrote: while (!tryWait(pp.pid).terminated) { auto cnt = read(fd, buf.ptr, buf.length); // C-style reading if (cnt == -1 && errno == EAGAIN) // C-style error checking yield(); else if (cnt > 0) { doSomething(buf[0..cnt]); yield(); } } IMHO a program should sleep (consume 0 CPU time and 0 energy) if there is nothing to process. This is best accomplished by not polling on a file descriptor in order to check if data has arrived. If your program must yield() there's probably something wrong with the design. I would suggest you put all the filedescriptors into a fd_set an then select(3) on the set.
Re: non-block reading from pipe stdout
On Tuesday, 3 October 2017 at 10:45:21 UTC, kdevel wrote: On Tuesday, 3 October 2017 at 00:22:28 UTC, Oleg B wrote: but get error "Resource temporarily unavailable". You get EAGAIN because there is no data available at the time of reading. From the manpage of read: ERRORS EAGAIN Non-blocking I/O has been selected using O_NONBLOCK and no data was immediately available for reading. I found only one way: C-style auto pp = pipeShell(updaterScriptCommand, Redirect.all, null, Config.none, workDir); import core.sys.posix.unistd : read; import core.stdc.errno; import core.sys.posix.fcntl; int fd = pp.stdout.fileno; int flags = fcntl(fd, F_GETFL, 0); flags |= O_NONBLOCK; fcntl(fd, F_SETFL, flags); // C-style setting file config char[256] buf; while (!tryWait(pp.pid).terminated) { auto cnt = read(fd, buf.ptr, buf.length); // C-style reading if (cnt == -1 && errno == EAGAIN) // C-style error checking yield(); else if (cnt > 0) { doSomething(buf[0..cnt]); yield(); } }
Re: non-block reading from pipe stdout
On Tuesday, 3 October 2017 at 11:36:28 UTC, Oleg B wrote: EAGAIN Non-blocking I/O has been selected using O_NONBLOCK and no data was immediately available for reading. And I can't check this without using exception handling? Your programm shall not read before data is available. Use core.sys.posix.sys.select to check if read would block on a blocking socket.
Does D support nested Templates aka Higher Kinded Polymorphism?
Especially, I mean something like T foo(S,T)(T i) { ... }
Re: Does D support nested Templates aka Higher Kinded Polymorphism?
On 03/10/2017 1:05 PM, sighoya wrote: Especially, I mean something like T foo(S,T)(T i) { ... } struct Foo(T) { T value; } T!S foo(S, alias T)(T!S v) { return v; } void main() { import std.stdio; writeln(foo!(int, Foo)(Foo!int(1))); }
Re: non-block reading from pipe stdout
On Tuesday, 3 October 2017 at 10:45:21 UTC, kdevel wrote: On Tuesday, 3 October 2017 at 00:22:28 UTC, Oleg B wrote: but get error "Resource temporarily unavailable". You get EAGAIN because there is no data available at the time of reading. From the manpage of read: ERRORS EAGAIN Non-blocking I/O has been selected using O_NONBLOCK and no data was immediately available for reading. And I can't check this without using exception handling?
Re: non-block reading from pipe stdout
On Tuesday, 3 October 2017 at 00:22:28 UTC, Oleg B wrote: but get error "Resource temporarily unavailable". You get EAGAIN because there is no data available at the time of reading. From the manpage of read: ERRORS EAGAIN Non-blocking I/O has been selected using O_NONBLOCK and no data was immediately available for reading.