Re: Dub use local fork
On Saturday, 23 September 2017 at 04:45:47 UTC, Mike Parker wrote: On Saturday, 23 September 2017 at 03:13:15 UTC, Nicholas Wilson wrote: my dub.selections.json is currently: { "fileVersion": 1, "versions": { "derelict-cl": "2.0.0", "derelict-cuda": "2.0.1", "derelict-util": "2.1.0", "taggedalgebraic": "0.10.7" } } I want derelict-cl to use C:\Users\me\Documents\GitHub\DerelictCL How do I do that? http://code.dlang.org/package-format?lang=json#version-specs "derelict-cl": { "path": "C:/Users/me/Documents/GitHub/DerelictCL" } Thanks!
Re: Dub use local fork
On Saturday, 23 September 2017 at 03:13:15 UTC, Nicholas Wilson wrote: my dub.selections.json is currently: { "fileVersion": 1, "versions": { "derelict-cl": "2.0.0", "derelict-cuda": "2.0.1", "derelict-util": "2.1.0", "taggedalgebraic": "0.10.7" } } I want derelict-cl to use C:\Users\me\Documents\GitHub\DerelictCL How do I do that? http://code.dlang.org/package-format?lang=json#version-specs "derelict-cl": { "path": "C:/Users/me/Documents/GitHub/DerelictCL" }
Re: Dub use local fork
On 23/09/2017 4:13 AM, Nicholas Wilson wrote: I want to use a fork of one of my dub dependencies so I can make sure that it works before I merge the fork into upstream. http://code.dlang.org/advanced_usage says Path-based dependencies Package descriptions in the dub.json/dub.sdl can specify a path instead of a version; this can be used with Git submodules or subtrees, or with a known directory layout, to use arbitrarily defined versions of a dependency. Note that this should only be used for non-public packages. Path-based selections You can specify arbitrary versions, branches, and paths in the dub.selections.json file, even if they contradict the dependency specification of the packages involved (note that DUB will output a warning in that case). but doesn't give any examples. my dub.selections.json is currently: { "fileVersion": 1, "versions": { "derelict-cl": "2.0.0", "derelict-cuda": "2.0.1", "derelict-util": "2.1.0", "taggedalgebraic": "0.10.7" } } I want derelict-cl to use C:\Users\me\Documents\GitHub\DerelictCL How do I do that? Thanks Nic Alternatively you can alter the package that dub already knows about. Does the trick more easily ;)
Dub use local fork
I want to use a fork of one of my dub dependencies so I can make sure that it works before I merge the fork into upstream. http://code.dlang.org/advanced_usage says Path-based dependencies Package descriptions in the dub.json/dub.sdl can specify a path instead of a version; this can be used with Git submodules or subtrees, or with a known directory layout, to use arbitrarily defined versions of a dependency. Note that this should only be used for non-public packages. Path-based selections You can specify arbitrary versions, branches, and paths in the dub.selections.json file, even if they contradict the dependency specification of the packages involved (note that DUB will output a warning in that case). but doesn't give any examples. my dub.selections.json is currently: { "fileVersion": 1, "versions": { "derelict-cl": "2.0.0", "derelict-cuda": "2.0.1", "derelict-util": "2.1.0", "taggedalgebraic": "0.10.7" } } I want derelict-cl to use C:\Users\me\Documents\GitHub\DerelictCL How do I do that? Thanks Nic
Re: Connecting python to D on socket of localhost : target machine actively refuses connection
On 23/09/2017 3:26 AM, Sergei Degtiarev wrote: On Friday, 22 September 2017 at 04:06:08 UTC, Enjoys Math wrote: Here's my minimal D code (server.d): public: this(ushort port, string address="") { super(& run); if (address == "") address = "DESKTOP-T49RGUJ"; this.port = port; this.address = address; . listener.bind(new InternetAddress(address, port)); It seems to me, you pass invalid address to bind(). InternetAddress takes ipv4 dot notation string x.x.x.x, and for bind you are to supply INADDR_ANY For DNS resolution: https://dlang.org/phobos/std_socket.html#.getAddress
Re: Connecting python to D on socket of localhost : target machine actively refuses connection
On Friday, 22 September 2017 at 04:06:08 UTC, Enjoys Math wrote: Here's my minimal D code (server.d): public: this(ushort port, string address="") { super(& run); if (address == "") address = "DESKTOP-T49RGUJ"; this.port = port; this.address = address; . listener.bind(new InternetAddress(address, port)); It seems to me, you pass invalid address to bind(). InternetAddress takes ipv4 dot notation string x.x.x.x, and for bind you are to supply INADDR_ANY
Re: How to list all process directories under /proc/
On Sunday, 17 September 2017 at 08:15:58 UTC, Ky-Anh Huynh wrote: Hi, I want to list all processes by scanning /proc/. The following code doesn't work [code] foreach (string fstatm; dirEntries("/proc/", "[0-9]*", SpanMode.shallow)) { writefln("pid %s", fstatm); } [/code] as it only list a few entries before exiting [code] pid /proc/9 pid /proc/935 pid /proc/9146 pid /proc/9149 pid /proc/9150 pid /proc/9151 pid /proc/9756 pid /proc/9759 pid /proc/9760 pid /proc/9761 [/code] I don't want to use `SpanMode.depth` or `SpanMode.breadth` because it will scan so deeply and there would be a permission problem. Any ideas? Thanks a lot Are you familiar with libprocps ? Maybe you had better make use of this library, or, at least, peek into its code, for reference.
Re: What the hell is wrong with D?
On Tuesday, 19 September 2017 at 18:34:13 UTC, Brad Anderson wrote: On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote: On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta wrote: Thanks for wasting some of my life... Just curious about who will justify the behavior and what excuses they will give. Pretty sure it would be exactly the same thing in C... It is (and Java and C# and pretty much every other C style language though the nicer implicit conversion rules means it gets caught more easily). It is a big source of programmer mistakes. It comes up frequently in PVS Studio's open source analysis write ups. So I checked for all the languages listed: C, C#, Java, Javascript, C++, PHP, Perl and D. All have the same order of precedence except, as always the abomination of all languages: C++ (kill it with fire). C++ is the only language that has the ternary operator have the same precedence than the assignment operators. This means a>=5?b=100:b=200; will compile in C++ but not in all the other languages. That's one reason why it irritates me when people continuously refer to C and C++ as if it was the same thing (yes I mean you Walter and Andrei). Even PHP and Perl got it right, isn't that testament of poor taste Bjarne?. :-)
Re: Multidimensional dynamic array of strings initialized with split()
On Thursday, 5 September 2013 at 16:22:46 UTC, Ali Çehreli wrote: Compiling with "DMD64 D Compiler v2.064-devel-52cc287" produces the following errors: * You had byLines in your original code as well. Shouldn't it be byLine? * You are missing the closing brace of the foreach loop as well. * "Error: cannot append type char[][] to type string[][]" I have to replace .dup with .idup Thank you for pointing out the errors, Ali. I have updated the example. The following version is lazy: import std.stdio; import std.array; import std.algorithm; auto readInData(File inputFile, string fieldSeparator) { return inputFile .byLine .map!(line => line .idup .split("\t")); } The caller can either use the result lazily: import std.range; void main() { auto file = File("deneme.txt"); writeln(readInData(file, "\t").take(2)); } Or call .array on the result to consume the range eagerly: auto table = readInData(file, "\t").array; Ali Thank you for the alternative approaches. This thread is linked from Credits section, if someone wants to find out more on the topic from the wiki.
CTFE static array error: cannot modify read-only constant
Hi all, ``` auto foo(const int[3] x) { int[3] y = x; y[0] = 1; // line 4 return y; } immutable int[3] a = [0,1,2]; immutable int[3] b = foo(a); // line 8 ``` compiles with an error: ``` 4: Error: cannot modify read-only constant [0, 1, 2] 8:called from here: foo(a) ``` What am I doing wrong? Thanks, Johan
Last post from me not displayed on web frontend?
This post is to try if it works now. But I got an answer from Adam... Thank you.
Parsing mbox file to display with vibe.d
Hello, Parsing mbox file (/var/spool/mail/... on a Ubuntu machine) and splitting to a range or array of mail objects. Has anyone done this with D? please give me hint. (DUB, git, this forum?) Or should I start with formail (-s) as a subprocess? (At first step, I want to run a vibe.d server to display all Cron Messages which I will forward to one special account to view them in a browser. At first I thought about setting up Squirrel Mail or something similar for the job, but then by simply splitting the mbox and displaying the content in a html-table I might get what I need. ) Regards mt.
Re: How to check if string is available at compile time
On Thursday, 21 September 2017 at 11:42:36 UTC, David Bennett wrote: Hi Guys, Is there an easy way to check if the value of string passed to a template is available at compile time? Yeah , sure and I have such a template in my library: https://github.com/BBasile/iz/blob/master/import/iz/types.d#L627 see just above too, the template "isCompileTimeValue"
Re: Problems with function as parameter
On Friday, 22 September 2017 at 04:32:08 UTC, Josh wrote: As an aside, in that doc it says "The .funcptr property of a delegate will return the function pointer value as a function type". So I also tried Mix_ChannelFinished((&channelDone).funcptr); and this compiled, but caused a segfault when the callback ran. What would have caused this? Is it because it's a C function? No it's because in this function are used variables that are specific to the class instance (the this). If there weren't this would work, even if it's not a good idea to do that: struct Foo { int a; void needThisYeahReally(){a = 0;} void needThisButWorkWithout(){} } void main() { Foo foo; { auto dg = &foo.needThisButWorkWithout; dg.funcptr(); } { auto dg = &foo.needThisYeahReally; // dg.funcptr(); // segfault because of access to this.a } } Using a pointer to a static member function was the right thing to do.