Re: User defined type and foreach

2017-11-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 17, 2017 07:40:35 Mike Parker via Digitalmars-d-learn wrote: > On Friday, 17 November 2017 at 03:15:12 UTC, Tony wrote: > > Thanks T! Good information, especially "iterating over a range > > is supposed to consume it". I have been reading > > dlang.org->Documentation->Language

Re: Class instance becoming null after calling bindings to C code???

2017-11-17 Thread Kagamin via Digitalmars-d-learn
And https://github.com/Extrawurst/DerelictFmod/issues/1

Re: writeln, alias this and dynamic arrays.

2017-11-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/17/17 8:13 AM, Adam D. Ruppe wrote: On Friday, 17 November 2017 at 06:57:16 UTC, Michael V. Franklin wrote: Actually, it looks like it's this 4-year old bug. https://issues.dlang.org/show_bug.cgi?id=9506 Yeah, I suspected this is old and my comment in there still applies... It passes

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-17 Thread kdevel via Digitalmars-d-learn
On Thursday, 16 November 2017 at 19:37:31 UTC, ade90036 wrote: Can we enable some sort of profiling to see what is going on? You may compile the code with dmd -g -O -profile -profile=gc I currently struggle getting meaningful output. I want to terminate the program after a number (say 400)

Re: writeln, alias this and dynamic arrays.

2017-11-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 November 2017 at 06:57:16 UTC, Michael V. Franklin wrote: Actually, it looks like it's this 4-year old bug. https://issues.dlang.org/show_bug.cgi?id=9506 Yeah, I suspected this is old and my comment in there still applies... It passes the isInputRange test due to the implicit

Re: Json

2017-11-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 17, 2017 19:02:12 Mafi via Digitalmars-d-learn wrote: > What is the current best practice for parsing JSON in D? What > library (on code.dlang.org) should I use? > > I do not want to (de-)serialize structs. Instead I want a simple > DOM-API. > > Thank you very much :) I've

Json

2017-11-17 Thread Mafi via Digitalmars-d-learn
What is the current best practice for parsing JSON in D? What library (on code.dlang.org) should I use? I do not want to (de-)serialize structs. Instead I want a simple DOM-API. Thank you very much :)

Re: User defined type and foreach

2017-11-17 Thread Tony via Digitalmars-d-learn
On Friday, 17 November 2017 at 07:40:35 UTC, Mike Parker wrote: You might also find use in this article (poorly adapted from Chapter 6 of Learning D by the publisher, but still readable): https://www.packtpub.com/books/content/understanding-ranges makes a distinction about "range

Re: User defined type and foreach

2017-11-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 17, 2017 17:37:01 Tony via Digitalmars-d-learn wrote: > On Friday, 17 November 2017 at 07:40:35 UTC, Mike Parker wrote: > > You might also find use in this article (poorly adapted from > > Chapter 6 of Learning D by the publisher, but still readable): > > > >

Re: User defined type and foreach

2017-11-17 Thread Tony via Digitalmars-d-learn
On Saturday, 18 November 2017 at 05:24:30 UTC, Tony wrote: Forgot to handle pre-mature foreach exit: import std.stdio : writeln; class RefRange { int foreach_index; int[] items; this(int[] src) { items = src; } bool empty() { if (foreach_index ==

Re: User defined type and foreach

2017-11-17 Thread Tony via Digitalmars-d-learn
On Friday, 17 November 2017 at 17:55:30 UTC, Jonathan M Davis wrote: When you have foreach(e; range) it gets lowered to something like for(auto r = range; !r.empty; r.popFront()) { auto e = r.front; } So, the range is copied when you use it in a foreach. In the case of a class, it's

Re: User defined type and foreach

2017-11-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 18, 2017 05:24:30 Tony via Digitalmars-d-learn wrote: > On Friday, 17 November 2017 at 17:55:30 UTC, Jonathan M Davis > > So, in the general case, if you want to use a range in foreach > > without consuming the range, it needs to be a forward range, > > and you need to call

Re: NIO+Multithreaded TCPSocket listener, very low cpu utilisation

2017-11-17 Thread kdevel via Digitalmars-d-learn
On Friday, 17 November 2017 at 14:28:38 UTC, kdevel wrote: On Thursday, 16 November 2017 at 19:37:31 UTC, ade90036 wrote: Can we enable some sort of profiling to see what is going on? You may compile the code with dmd -g -O -profile -profile=gc I currently struggle getting meaningful output.

Call thread_attachThis() from your D shared library

2017-11-17 Thread Ali Çehreli via Digitalmars-d-learn
We had an issue today calling a D shared library from our Java code where we were getting segfaults during GC collection cycles. Of course we were being careful and calling Runtime.initialize() inside our initialization function, which is called from the Java side: extern (C) auto