Re: dub command line in config?
On Sunday, 9 October 2016 at 05:09:28 UTC, Mike Parker wrote: On Saturday, 8 October 2016 at 23:05:51 UTC, Jinx wrote: how to add command line options to the dub.json so they do not have to be typed on the command line every time? AFAIK, there's not support for this. Is it really necessary, though? It's a one line shell script. huh? Yes it is necessary. How hard could it be. Editing a script is the same as editing the json file and creates junk files. Why make things harder than they have to be? Seems like it would be rather trivial to implement.
Re: dub command line in config?
On Saturday, 8 October 2016 at 23:05:51 UTC, Jinx wrote: how to add command line options to the dub.json so they do not have to be typed on the command line every time? AFAIK, there's not support for this. Is it really necessary, though? It's a one line shell script.
Re: Beginner DUB user question...
On Sunday, 9 October 2016 at 01:24:57 UTC, WhatMeWorry wrote: I've got a little hello_window DUB project which uses these dependencies: dependency "derelict-util" version="~>2.0.6" dependency "derelict-glfw3" version="~>3.1.0" dependency "derelict-gl3" version="~>1.0.19" dependency "derelict-fi"version="~>2.0.3" dependency "derelict-ft"version="~>1.1.2" dependency "derelict-al"version="~>1.0.1" dub run --verbose --arch=x86_64 --force successfully compiles and links hello_window.exe Going forward, I want to reuse common code, so I created a sub-directory called appropiately enough: common. And to quote M. Parker's Learning D, "...for imported modules to be compiled and linked, they should be passed to the compiler as well." So how do I get dub to call dmd with this pattern? dmd hellow_window.d common/load_libraries.d Subpackages are useful if you have mutiple projects in the same git repository. Otherwise, there are several ways to go about this, depending on what your intentions and what your directory structure looks like. Is the common subdirectory part of the same project? Is it an independent project you want to share between multiple projects? Are you planning on distributing the code (e.g. on github) or is it only for your local build system? If common is an independent project with its own dub configuration, then you might use `dub add-local` to make it available to all of your other projects or, if you don't plan to distribute it, use a `path` instead of `version` for any projects that depend on it (in project A's dub.sdl: dependency "libcommon" path="../path/to/common"). If common is not an independent project (it has no dub configuration) then you can use `sourcePaths` (or `sourceFiles`) in the dub configuration of any projects that need it. Or you could copy it around into the source directory of any project that uses it and dub will compile it automatically: - projectA -- dub.sdl --- source projecta common
Re: Beginner DUB user question...
On 09/10/2016 2:24 PM, WhatMeWorry wrote: I've got a little hello_window DUB project which uses these dependencies: dependency "derelict-util" version="~>2.0.6" dependency "derelict-glfw3" version="~>3.1.0" dependency "derelict-gl3" version="~>1.0.19" dependency "derelict-fi"version="~>2.0.3" dependency "derelict-ft"version="~>1.1.2" dependency "derelict-al"version="~>1.0.1" dub run --verbose --arch=x86_64 --force successfully compiles and links hello_window.exe Going forward, I want to reuse common code, so I created a sub-directory called appropiately enough: common. And to quote M. Parker's Learning D, "...for imported modules to be compiled and linked, they should be passed to the compiler as well." So how do I get dub to call dmd with this pattern? dmd hellow_window.d common/load_libraries.d Thanks. Sounds like you want subpackages.
Beginner DUB user question...
I've got a little hello_window DUB project which uses these dependencies: dependency "derelict-util" version="~>2.0.6" dependency "derelict-glfw3" version="~>3.1.0" dependency "derelict-gl3" version="~>1.0.19" dependency "derelict-fi"version="~>2.0.3" dependency "derelict-ft"version="~>1.1.2" dependency "derelict-al"version="~>1.0.1" dub run --verbose --arch=x86_64 --force successfully compiles and links hello_window.exe Going forward, I want to reuse common code, so I created a sub-directory called appropiately enough: common. And to quote M. Parker's Learning D, "...for imported modules to be compiled and linked, they should be passed to the compiler as well." So how do I get dub to call dmd with this pattern? dmd hellow_window.d common/load_libraries.d Thanks.
dub command line in config?
how to add command line options to the dub.json so they do not have to be typed on the command line every time?
weighted round robin
Hi, Can some one guide me on how to implement the weighted round robin, below is what i tried or any other better ways to do it Main Requirement : Incoming socket connection has to be sent to 3 servers in the weighted round robin fashion. Prog:1 import std.stdio; import std.range; import std.range.primitives; void main() { auto a = [1,2,3]; // E.g :Server Array auto b = [1,2,3,4,5]; // E.g: Socket Array auto r = roundRobin(a, b); writeln(r); } OUTPUT : [1, 1, 2, 2, 3, 3, 4, 5] Requirement : [1, 1, 2, 2, 3, 3,1,4,2,5] From, Vino
Re: Why can't static arrays be sorted?
On Thursday, 6 October 2016 at 20:11:17 UTC, ag0aep6g wrote: On 10/06/2016 09:54 PM, TheGag96 wrote: Interestingly enough, I found that using .each() actually compiles without the [] [...] why can the compiler consider it a range here but not .sort()? each is not restricted to ranges. It accepts other `foreach`-ables, too. The documentation says that it "also supports opApply-based iterators", but it's really anything that foreach accepts. [snip] Thanks! Explains some things. I knew each! was callable in different circumstances than other functional operations, but hadn't quite figured it out. Looks like reduce! and fold! also take iterables. There also appears to be a distinction between the iterator and range cases when a ref parameter is used. As it iterator, each! won't modify the reference. Example: void main() { import std.algorithm : each; int[] dynamicArray = [1, 2, 3, 4, 5]; int[5] staticArray = [1, 2, 3, 4, 5]; dynamicArray.each!((ref x) => x++); assert(dynamicArray == [2, 3, 4, 5, 6]); // modified staticArray.each!((ref x) => x++); assert(staticArray == [1, 2, 3, 4, 5]); // not modified staticArray[].each!((ref x) => x++); assert(staticArray == [2, 3, 4, 5, 6]); // modified } This distinction is a bit on the nuanced side. Is it behaving as it should? --Jon
Re: Easy sockets - don't exist yet?
On Monday, 26 September 2016 at 23:40:10 UTC, Vincent wrote: Hello, guys! I was very surprised that module 'socketstream' was deprecated. Usually if something become obsolete, there is some perfect replacement! But my digging in Inet and forums gave nothing, but "outdated" examples with 'SocketStream' class. So first question is WHAT Phobos has to replace SocketStream? To avoid unnecessary mail bouncing, I write upfront what I expect from normal Socket implementation (kind of interface) : [...] This is how a usable socket in a standard library should be http://dsfml.com/docs/sockets.html. This is using DSFML (a D bindings to SFML).
Re: How do I load a shared library?
On Saturday, 8 October 2016 at 13:46:50 UTC, Adam D. Ruppe wrote: On Saturday, 8 October 2016 at 07:33:30 UTC, Nafees wrote: It compiles fine, but when I run loader, it crashes as soon as dlopen is called, giving a segFault. What output do you get? If you compile with `-g` to dmd and run it in gdb, you can also use the command `where` to gdb and get a file/line number for the segfault. What does it say? http://imgur.com/U9ZYhVKl.png
Re: Basic sounds' playing
On Saturday, 8 October 2016 at 13:35:57 UTC, Cleverson Casarin Uliana wrote: Thank you Vadim and John, the PlaySound function is enough for now. I'm not yet developing an app, just experimenting with some exercises. The wasapi library seems interesting, does it also implement a playSound-like function? Greetings Cleverson WASAPI looks more complicated - see this sample for playing a file https://msdn.microsoft.com/en-us/library/windows/desktop/dd316756(v=vs.85).aspx
Re: How do I load a shared library?
On Saturday, 8 October 2016 at 07:33:30 UTC, Nafees wrote: It compiles fine, but when I run loader, it crashes as soon as dlopen is called, giving a segFault. What output do you get? If you compile with `-g` to dmd and run it in gdb, you can also use the command `where` to gdb and get a file/line number for the segfault. What does it say?
Re: Basic sounds' playing
Thank you Vadim and John, the PlaySound function is enough for now. I'm not yet developing an app, just experimenting with some exercises. The wasapi library seems interesting, does it also implement a playSound-like function? Greetings Cleverson
Re: Why can't static arrays be sorted?
On Thursday, 6 October 2016 at 09:23:19 UTC, pineapple wrote: On Thursday, 6 October 2016 at 09:17:08 UTC, pineapple wrote: On Wednesday, 5 October 2016 at 19:30:01 UTC, Jonathan M Davis wrote: Would just like to point out that this is design weirdness on Phobos' part - the library I've been writing does not have this problem. It doesn't even make conceptual sense for a static array to be a range, because you can't remove elements from it. - Jonathan M Davis Just because the static array itself isn't a range doesn't mean that it should be necessary to do unintuitive gymnastics with it just to pass it to functions like `sort`. I mean, people post here how often asking why static or dynamic arrays aren't being accepted by Phobos' range functions in their code? Maybe Phobos really ought to consider another approach. Accepting things that are _valid_ as ranges and not only things that are ranges themselves has proven to be an effective strategy in mach. +1000
Re: Basic sounds' playing
On Saturday, 8 October 2016 at 01:00:20 UTC, Cleverson Casarin Uliana wrote: Hello all, starting to learn d, apreciating it so far. I'd like to play/stop wave sound files assynchronously on Windows. Can I get a module for that by installing a particular compiler, or is there any package for it instead? Thank you, Cleverson For basic playback of wave files, you could use the native PlaySound function, imported in core.sys.windows.mmsystem. https://msdn.microsoft.com/en-us/library/windows/desktop/dd743680(v=vs.85).aspx
How do I load a shared library?
I've seen the page on how to load/make Shared Libraries, but it doesn't work as mentioned here https://dlang.org/dll-linux.html#dso10 I have 2 files: lib.d contains: import core.stdc.stdio; extern (C) int dll() { printf("dll()\n"); return 0; } shared static this() { printf("libdll.so shared static this\n"); } shared static ~this() { printf("libdll.so shared static ~this\n"); } and loader.d contains: import core.stdc.stdio; import core.stdc.stdlib; import core.sys.posix.dlfcn; extern (C) int dll(); int main() { printf("+main()\n"); void* lh = dlopen("/home/nafees/Desktop/temp/libdll.so", RTLD_LAZY); //The path is absolutely correct if (!lh) { fprintf(stderr, "dlopen error: %s\n", dlerror()); exit(1); } printf("libdll.so is loaded\n"); int function() fn = cast(int function())dlsym(lh, "dll"); char* error = dlerror(); if (error) { fprintf(stderr, "dlsym error: %s\n", error); exit(1); } printf("dll() function is found\n"); fn(); printf("unloading libdll.so\n"); dlclose(lh); printf("-main()\n"); return 0; } shared static this() { printf("main shared static this\n"); } shared static ~this() { printf("main shared static ~this\n"); } I compile lib.d using the -shared & -m32 switches, and loader.d with -m32 switch (I want the result to be n 32 bit). It compiles fine, but when I run loader, it crashes as soon as dlopen is called, giving a segFault. I am using latest DMD, on xubuntu 16.04.