release building problem
When I build my program with release flag I get an errors, in debug build all works .dub/build/application-profile-linux.posix-x86_64-dmd-AD20DEA65FEE410217932549C1D262EF/ftree.o: In function `_D3des4flow5event5Event27__T6__ctorTS6client6ClientZ6__ctorMFNcmKxS6client6ClientZS3des4flow5event5Event': /home/deviator/workspace/cdsd/fractaltree/descore/import/des/flow/event.d:62: undefined reference to `_D6object43__T4_dupTxS6client6ClientTyS6client6ClientZ4_dupFNaNbAxS6client6ClientZAyS6client6Client' .dub/build/application-profile-linux.posix-x86_64-dmd-AD20DEA65FEE410217932549C1D262EF/ftree.o: In function `_D3des4util5pdata5PData27__T6__ctorTS6client6ClientZ6__ctorMFNaNbNcNfKxS6client6ClientZS3des4util5pdata5PData': /home/deviator/workspace/cdsd/fractaltree/descore/import/des/util/pdata.d:40: undefined reference to `_D6object43__T4_dupTxS6client6ClientTyS6client6ClientZ4_dupFNaNbAxS6client6ClientZAyS6client6Client' .dub/build/application-profile-linux.posix-x86_64-dmd-AD20DEA65FEE410217932549C1D262EF/ftree.o: In function `_D4sock2we6SockWE10emitEventsMFZv': /home/deviator/workspace/cdsd/fractaltree/src/sock/we.d:134: undefined reference to `_D6object43__T4_dupTxS6client6ClientTyS6client6ClientZ4_dupFNaNbAxS6client6ClientZAyS6client6Client' It may be a compiler bug, but now I must find workaround. From mangle `_D6object43__T4_dupTxS6client6ClientTyS6client6ClientZ4_dupFNaNbAxS6client6ClientZAyS6client6Client' I can understood what no 'dup(Client)' function. But I dont understand where it calls. Ctors flow.event.Event and des.util.pdata.PData looks like 'this(T)( ref const(T) val )' and dont use 'dup' function. Whey use 'idup' function for 'T[]'. struct Client { size_t id; vec3 orient; // struct vec3 { float[3] data; } vec3 motion; float p1; } Where I must find solution?
Re: release building problem
On 3/12/2014 11:15 p.m., Oleg wrote: When I build my program with release flag I get an errors, in debug build all works .dub/build/application-profile-linux.posix-x86_64-dmd-AD20DEA65FEE410217932549C1D262EF/ftree.o: In function `_D3des4flow5event5Event27__T6__ctorTS6client6ClientZ6__ctorMFNcmKxS6client6ClientZS3des4flow5event5Event': /home/deviator/workspace/cdsd/fractaltree/descore/import/des/flow/event.d:62: undefined reference to `_D6object43__T4_dupTxS6client6ClientTyS6client6ClientZ4_dupFNaNbAxS6client6ClientZAyS6client6Client' .dub/build/application-profile-linux.posix-x86_64-dmd-AD20DEA65FEE410217932549C1D262EF/ftree.o: In function `_D3des4util5pdata5PData27__T6__ctorTS6client6ClientZ6__ctorMFNaNbNcNfKxS6client6ClientZS3des4util5pdata5PData': /home/deviator/workspace/cdsd/fractaltree/descore/import/des/util/pdata.d:40: undefined reference to `_D6object43__T4_dupTxS6client6ClientTyS6client6ClientZ4_dupFNaNbAxS6client6ClientZAyS6client6Client' .dub/build/application-profile-linux.posix-x86_64-dmd-AD20DEA65FEE410217932549C1D262EF/ftree.o: In function `_D4sock2we6SockWE10emitEventsMFZv': /home/deviator/workspace/cdsd/fractaltree/src/sock/we.d:134: undefined reference to `_D6object43__T4_dupTxS6client6ClientTyS6client6ClientZ4_dupFNaNbAxS6client6ClientZAyS6client6Client' It may be a compiler bug, but now I must find workaround. From mangle `_D6object43__T4_dupTxS6client6ClientTyS6client6ClientZ4_dupFNaNbAxS6client6ClientZAyS6client6Client' I can understood what no 'dup(Client)' function. But I dont understand where it calls. Ctors flow.event.Event and des.util.pdata.PData looks like 'this(T)( ref const(T) val )' and dont use 'dup' function. Whey use 'idup' function for 'T[]'. struct Client { size_t id; vec3 orient; // struct vec3 { float[3] data; } vec3 motion; float p1; } Where I must find solution? So are you running dub with --build=release? Because from what I can see, its building as if it was --build=profile. And -profile arg in my experiance has a rather awful tendency to causing this.
Ncurses deprecated ~master issue
Sorry if this is a little off-topic, I posted this in the Dub forum on 23/11/14 but have had no reply yet: --- I read that the use of a branch spec like ~master in dub.json is deprecated. I also read that it could be overriden on a per-project basis by editing the project's dub.selections.json file but I can't find any information about what is actually required in this file and whether any corresponding changes need to be made to dub.json. I'm trying to use 'ncurses' which doesn't have a version number, only ~master. --- Also, does anyone know how 'beta' the ncurses module actually is, is anyone using it? Cheers Paul
Re: release building problem
the same result of building release or profile
template bug?
Hi, Is this a bug in the compiler? import std.stdio; import std.typetuple; class A { int foo() { return 0; } } class B : A { alias A.foo foo; override int foo() { return 1; } } template ItemProperty(item, string method) { static if(__traits(hasMember, item, method)) { static if(__traits(getProtection, ItemProperty!(item, method)).stringof[1..$-1] == public) { alias ItemProperty = TypeTuple!(ItemProperty!(item, method)); } else { alias ItemProperty = TypeTuple!(); } } else { alias ItemProperty = TypeTuple!(); } } void test()() { static if(ItemProperty!(B, foo).length 1) { writeln(found); } else { writeln(not found); } } void main() { test; }
Re: Ncurses deprecated ~master issue
On 12/03/2014 07:07 AM, Paul wrote: Sorry if this is a little off-topic, I posted this in the Dub forum on 23/11/14 but have had no reply yet: --- I read that the use of a branch spec like ~master in dub.json is deprecated. I also read that it could be overriden on a per-project basis by editing the project's dub.selections.json file but I can't find any information about what is actually required in this file and whether any corresponding changes need to be made to dub.json. I'm trying to use 'ncurses' which doesn't have a version number, only ~master. --- Also, does anyone know how 'beta' the ncurses module actually is, is anyone using it? Cheers Paul So, as far as I know there isn't any plan for versioning that specific library. I've used it, however, and it's pretty usable (as much as ncurses goes, at any rate). -- Matt Soucy http://msoucy.me/ signature.asc Description: OpenPGP digital signature
Re: template bug?
On 12/03/2014 09:10 AM, gedaiu wrote: Hi, Is this a bug in the compiler? Attempting to compile with a recent dmd git head causes segmentation fault. Any compiler crash is a compiler bug. Please report it at https://issues.dlang.org/ Ali
Re: curl: catching exception on connect.
On 12/02/2014 05:19 AM, Suliman wrote: connect() sends a CONNECT request to the server, as defined by HTTP [1]. This method is only used when you're working with proxies and the like. What you most likely want, however, is a GET request. Use get() for that. So what is the best way to check status server response (400, 404 etc) to send get request and try to parse response, or there is any better way (probably with another lib?)? connect() uses the curl.HTTP struct, which is available to us as well: http://dlang.org/phobos/std_net_curl.html#HTTP I added two lines to the first example there: import std.net.curl, std.stdio; pragma(lib, curl); void main() { // Get with custom data receivers auto http = HTTP(dlang.org); http.onReceiveHeader = (in char[] key, in char[] value) { writeln(key ~ : ~ value); }; http.onReceive = (ubyte[] data) { /+ drop +/ return data.length; }; http.perform(); const HTTP.StatusLine statusLine = http.statusLine(); writefln(GET request completed with code %s, statusLine.code); } Sample output: date: Wed, 03 Dec 2014 18:19:15 GMT server: Apache/2.2.22 (FreeBSD) PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8x DAV/2 last-modified: Sun, 02 Nov 2014 06:38:55 GMT etag: 3b438-4f9a-506da7be81dc0 accept-ranges: bytes content-length: 20378 content-type: text/html GET request completed with code 200 Ali
Re: template bug?
Ali Çehreli: Attempting to compile with a recent dmd git head causes segmentation fault. Any compiler crash is a compiler bug. Please report it at https://issues.dlang.org/ Ali A first reduction for Bugzilla: alias TypeTuple(T...) = T; struct A { void foo() {} } template ItemProperty(item, string method) { static if(__traits(getProtection, ItemProperty!(item, method)).stringof) alias ItemProperty = TypeTuple!(ItemProperty!(item, method)); } void main() { auto l = ItemProperty!(A, foo).length; } Bye, bearophile
Re: Ncurses deprecated ~master issue
On Wednesday, 3 December 2014 at 17:37:18 UTC, Matt Soucy wrote: On 12/03/2014 07:07 AM, Paul wrote: Sorry if this is a little off-topic, I posted this in the Dub forum on 23/11/14 but have had no reply yet: --- I read that the use of a branch spec like ~master in dub.json is deprecated. I also read that it could be overriden on a per-project basis by editing the project's dub.selections.json file but I can't find any information about what is actually required in this file and whether any corresponding changes need to be made to dub.json. I'm trying to use 'ncurses' which doesn't have a version number, only ~master. --- Also, does anyone know how 'beta' the ncurses module actually is, is anyone using it? Cheers Paul So, as far as I know there isn't any plan for versioning that specific library. I've used it, however, and it's pretty usable (as much as ncurses goes, at any rate). So do I manually add those source files to my program (assuming the ncurses libs are installed) if compiling with dmd rather than using dub?
Re: threading issues with D - C - Python
On Wednesday, 3 December 2014 at 06:11:56 UTC, Ellery Newcomer wrote: are you looking at this pyd: https://bitbucket.org/ariovistus/pyd I'm looking at this one, which is what came up when googling python to D http://pyd.dsource.org/
Re: threading issues with D - C - Python
On Wednesday, 3 December 2014 at 06:30:07 UTC, Russel Winder via Digitalmars-d-learn wrote: As far as I can tell PyD is still active, but in a non-funded FOSS way, i.e. work happens as and when volunteers put time and effort in. I haven't tried PyD recently but it worked fine last time I did. If can set out what you tried and what didn't work, maybe there is a PyD solution, or a fix to PyD to give a solution? Yeah apparently I might have used the wrong PyD. This might end up being all I need to do to fix my problem. D's big problem is shared objects/dynamic link libraries. Without them you cannot interwork with Python at all. I have tried experiments on Linux creating shared libraries from D code with C linkage entry points to create classic Python extensions, and it appears to work fine. Except for having to start up the D heap and thread management, should they be needed. But that is what PyD is there for. If I took my experiments any further I would end up recreating PyD or something like it. This is what I'm doing. I'm using the rt_init() function to setup the heap/thread management. Am I missing anything else here? It seems the issue is definitely more complicated than that. I'll also point out that: http://dlang.org/interfaceToC had no information on calling rt_init first, although it seems like it should. It sounds like you are in a similar situation except that you appear to have an extra layer of C code. I am not sure a layer of C is needed between Python and D, it would be good to know more about why you seem to need it. Well I wanted to compile D code and directly call it in Python, and since PyD didn't work for me, I instead tried the python- C interface I already knew (https://docs.python.org/2/c-api/index.html) and worked my way through a C-D interface, which I understood to be relatively simple. My guess would be not properly initializing the D infrastructure from the incoming Python thread. I would suggest that you want to avoid threads crossing the boundaries and just pass data via a shared channel. Unix pipes seem to work well in this context since they provide a language independent data channel. Yeah I'm leaning in that direction myself, although I might try the other PyD library first. I wanted to be able to use the D message-passing libraries to do the thread-safety stuff at first, because it was much easier than the alternative, but I'm not sure that's true anymore.
Sorted Array Wrapper Range
Have anybody written a generic automatically sorted range wrapper for RandomAccessRanges? I guess http://dlang.org/library/std/range/assumeSorted.html should play a key role. I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearch
Re: threading issues with D - C - Python
On Wed, 03 Dec 2014 20:41:46 + Michael via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 3 December 2014 at 06:11:56 UTC, Ellery Newcomer wrote: are you looking at this pyd: https://bitbucket.org/ariovistus/pyd I'm looking at this one, which is what came up when googling python to D http://pyd.dsource.org/ ah, dsource strikes back! that vile site keep biting us again and again. let's hope that new admins will kill it for good. signature.asc Description: PGP signature
Re: How to ensure a thread cannot be blocked by the GC?
On Wednesday, 3 December 2014 at 22:53:48 UTC, ponce wrote: I have a DLL written in D that gets called by two different threads, created by a non-D host program (audio plugin). I did not create those threads, but my understanding is that they get attached to the D runtime. Thread A is a real-time callback and should not ever block. @nogc seems perfect for this. Thread B and it's impractical to make it @nogc. How to ensure that a collection triggered by thread B never stop thread A in stop the world collections? Correction: Thread B isn't real-time, allocates, and it's impractical to make it @nogc.
How to ensure a thread cannot be blocked by the GC?
I have a DLL written in D that gets called by two different threads, created by a non-D host program (audio plugin). I did not create those threads, but my understanding is that they get attached to the D runtime. Thread A is a real-time callback and should not ever block. @nogc seems perfect for this. Thread B and it's impractical to make it @nogc. How to ensure that a collection triggered by thread B never stop thread A in stop the world collections?
Is this a bug or am I doing something wrong?
Check out http://dpaste.dzfl.pl/a5ada78fccf5 If my function named IWillNotCompile is run, I get an error stating Component!int' and 'Component!int' are not compatible. If my function named IWillCompile is run, there are no errors. They do the same thing, just written slightly differently. Any suggestions?
Re: Is this a bug or am I doing something wrong?
On 12/03/2014 03:02 PM, drsneed wrote: Check out http://dpaste.dzfl.pl/a5ada78fccf5 If my function named IWillNotCompile is run, I get an error stating Component!int' and 'Component!int' are not compatible. If my function named IWillCompile is run, there are no errors. They do the same thing, just written slightly differently. Any suggestions? Unlike C++, rvalues cannot be bound to reference parameters even if reference to const. Make the parameter 'auto ref' and it will compile: Component!(T) opBinary(string op)(auto ref Component!(T) rhs) For auto ref, the function must be a template so that the compiler can generate by-reference and by-value versions of it depending on whether the argument is lvalue versus rvalue. Here is my understanding of the issue: http://ddili.org/ders/d.en/lvalue_rvalue.html Ali
Re: Is this a bug or am I doing something wrong?
On Wednesday, 3 December 2014 at 23:09:02 UTC, Ali Çehreli wrote: On 12/03/2014 03:02 PM, drsneed wrote: Check out http://dpaste.dzfl.pl/a5ada78fccf5 If my function named IWillNotCompile is run, I get an error stating Component!int' and 'Component!int' are not compatible. If my function named IWillCompile is run, there are no errors. They do the same thing, just written slightly differently. Any suggestions? Unlike C++, rvalues cannot be bound to reference parameters even if reference to const. Make the parameter 'auto ref' and it will compile: Component!(T) opBinary(string op)(auto ref Component!(T) rhs) For auto ref, the function must be a template so that the compiler can generate by-reference and by-value versions of it depending on whether the argument is lvalue versus rvalue. Here is my understanding of the issue: http://ddili.org/ders/d.en/lvalue_rvalue.html Ali Ahh, I'm used to the c++ style. Nice write-up on the matter, and thanks for the help!
Re: How to ensure a thread cannot be blocked by the GC?
On Wednesday, 3 December 2014 at 22:53:48 UTC, ponce wrote: I have a DLL written in D that gets called by two different threads, created by a non-D host program (audio plugin). I did not create those threads, but my understanding is that they get attached to the D runtime. Thread A is a real-time callback and should not ever block. @nogc seems perfect for this. Thread B and it's impractical to make it @nogc. How to ensure that a collection triggered by thread B never stop thread A in stop the world collections? I assume you are referring to Windows and I have no good answer for you. Could it not vary between implementations or is it language defined? However, a real time thread ought to be specified by the OS as being non-interruptable (but with a timeout). Otherwise it should not be labeled as realtime… AudioUnits on OS-X are called with realtime priority. IRRC the D GC uses SIGUSR1 on unix, so there you should be able to specify a signal mask to tell the OS whether to block the thread on collection or not.
Re: How to ensure a thread cannot be blocked by the GC?
On Thursday, 4 December 2014 at 00:27:49 UTC, Ola Fosheim Grøstad wrote: I assume you are referring to Windows and I have no good answer Btw, I found this page to be a nice starting point and generally a good read for writing portable code: http://msdn.microsoft.com/en-us/library/ms811896.aspx
Re: threading issues with D - C - Python
On Wednesday, 3 December 2014 at 21:35:48 UTC, ketmar via Digitalmars-d-learn wrote: ah, dsource strikes back! that vile site keep biting us again and again. let's hope that new admins will kill it for good. Yeah. I've got the new PyD and it compiles and does everything I want much nicer, but it appears to have the exact same problems. When calling a python thread to my code, it can cause segfaults and hanging issues. Cheers, Michael.
Re: How to ensure a thread cannot be blocked by the GC?
On Thursday, 4 December 2014 at 00:27:49 UTC, Ola Fosheim Grøstad wrote: IRRC the D GC uses SIGUSR1 on unix, so there you should be able Hmmm, I have no idea why I wrote this. According to the code for the runtime it only suspends threads that inherit from Thread? GC fullcollect calls thread_suspendAll which traverses a linked list of Threads. So I suppose none of your threads are suspended unless you suspend it with Thread on call_back entry? But why suspend a @nogc thread? https://github.com/D-Programming-Language/druntime/blob/master/src/core/thread.d#L2501 https://github.com/D-Programming-Language/druntime/blob/master/src/gc/gc.d#L2479
Re: How to ensure a thread cannot be blocked by the GC?
On Thursday, 4 December 2014 at 01:36:13 UTC, Ola Fosheim Grøstad wrote: So I suppose none of your threads are suspended unless you suspend it with Thread on call_back entry? But why suspend a @nogc thread? What a mess of incorrect recollection and typos (it is late, 3AM :-P): I meant to say that I suppose none of your threads are suspended unless you register it as a Thread before the call_back entry. But if you do it on the call_back entry point by registering a fake Thread object you must ensure that you are not already in a collection cycle before continuing… Seems to me that there should either be better documentation of GC behaviour or some extra functionality for controlling GC interference with threads and Threads. I also find this confusing… There is a lot of policy making in D's runtime and standard library.
Re: threading issues with D - C - Python
On 12/03/2014 04:43 PM, Michael wrote: On Wednesday, 3 December 2014 at 21:35:48 UTC, ketmar via Digitalmars-d-learn wrote: ah, dsource strikes back! that vile site keep biting us again and again. let's hope that new admins will kill it for good. Yeah. I've got the new PyD and it compiles and does everything I want much nicer, but it appears to have the exact same problems. When calling a python thread to my code, it can cause segfaults and hanging issues. Cheers, Michael. okay. that's not too surprising. If you can get me a minimal example, I'd be happy to have a look since pyd should probably support this case.
Re: threading issues with D - C - Python
On Thursday, 4 December 2014 at 02:31:51 UTC, Ellery Newcomer wrote: okay. that's not too surprising. If you can get me a minimal example, I'd be happy to have a look since pyd should probably support this case. Cool. Unfortunately most of the times I've attempted to reduce this down it always seems to work, but I think that's because I often did the example code in D. I'll play around with it and try to send you an example. Cheers, Michael.
Re: Why the DMD Backend?
On Friday, 28 November 2014 at 20:14:07 UTC, LeakingAntonovPlane wrote: DDMD, bootstraping. LDC and GDC are not written in D. Pretty sure that DDMD project is not a translation of the backend and is only the shared front end source code.
Re: threading issues with D - C - Python
On 12/03/2014 06:56 PM, Michael wrote: On Thursday, 4 December 2014 at 02:31:51 UTC, Ellery Newcomer wrote: okay. that's not too surprising. If you can get me a minimal example, I'd be happy to have a look since pyd should probably support this case. Cool. Unfortunately most of the times I've attempted to reduce this down it always seems to work, but I think that's because I often did the example code in D. I'll play around with it and try to send you an example. Cheers, Michael. dustmite?
Re: Sorted Array Wrapper Range
On Wednesday, 3 December 2014 at 21:02:05 UTC, Nordlöw wrote: Have anybody written a generic automatically sorted range wrapper for RandomAccessRanges? I guess http://dlang.org/library/std/range/assumeSorted.html should play a key role. I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearch There was a relevant discussion about a month ago here: http://forum.dlang.org/thread/uhfpppdslxdghycon...@forum.dlang.org Otherwise, there's RedBlackTree, but I'm not aware of anything that works over any random-access range.
Re: More flexible sorted ranges?
On Sunday, 2 November 2014 at 15:13:37 UTC, bearophile wrote: SortedRange!(Foo[], q{ a.x b.x }) data; data ~= Foo(5); immutable n = data.upperBound(Foo(2)).length; Have anybody implemented SortedRange? I can't find any refs.
Re: Sorted Array Wrapper Range
On Thursday, 4 December 2014 at 04:24:26 UTC, Xinok wrote: There was a relevant discussion about a month ago here: http://forum.dlang.org/thread/uhfpppdslxdghycon...@forum.dlang.org I can't any reference to code, typically for SortedRange. Has this been implemented somewhere?