Re: Strange closure behaviour

2019-06-14 Thread Emmanuelle via Digitalmars-d-learn
On Saturday, 15 June 2019 at 00:30:43 UTC, Adam D. Ruppe wrote: On Saturday, 15 June 2019 at 00:24:52 UTC, Emmanuelle wrote: Is it a compiler bug? Yup, a very longstanding bug. You can work around it by wrapping it all in another layer of function which you immediately call (which is fairly

Re: Strange closure behaviour

2019-06-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 June 2019 at 00:24:52 UTC, Emmanuelle wrote: Is it a compiler bug? Yup, a very longstanding bug. You can work around it by wrapping it all in another layer of function which you immediately call (which is fairly common in javascript): funcs ~= ((x) => (int i) { nums

Strange closure behaviour

2019-06-14 Thread Emmanuelle via Digitalmars-d-learn
Take a look at this code: --- import std.stdio; void main() { alias Func = void delegate(int); int[][] nums = new int[][5]; Func[] funcs; foreach (x; 0 .. 5) { funcs ~= (int i) { nums[x] ~= i; }; } foreach (i, func; funcs) { func(cast(int) i); }

Re: How to compile my DMD fork?

2019-06-14 Thread Max Haughton via Digitalmars-d-learn
On Friday, 14 June 2019 at 18:07:11 UTC, Q. Schroll wrote: Basically the headline. I want to try to implement my DIP. I've already forked DMD from GitHub. Now, what would I have to do in order to get a D compiler with my changes? I have Windows on x86-64 and Visual Studio on my machine. It m

Re: OT (Was: Re: is(ElementType!(char[2]) == dchar - why?)

2019-06-14 Thread Yatheendra via Digitalmars-d-learn
Could this be rendered an aside for newbies, by way of documentation, specifically the Unicode portion of the Dlang tour? Just never bring up auto-decoding at all, point out UTF8/16/32 and point out the fast correct primitive (byCodeUnit) that lets you iterate over a string's contents simplisti

Re: How to compile my DMD fork?

2019-06-14 Thread kinke via Digitalmars-d-learn
On Friday, 14 June 2019 at 18:07:11 UTC, Q. Schroll wrote: Basically the headline. I want to try to implement my DIP. I've already forked DMD from GitHub. Now, what would I have to do in order to get a D compiler with my changes? I have Windows on x86-64 and Visual Studio on my machine. Inst

Re: How to compile my DMD fork?

2019-06-14 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 14, 2019 at 06:07:11PM +, Q. Schroll via Digitalmars-d-learn wrote: > Basically the headline. I want to try to implement my DIP. I've > already forked DMD from GitHub. Now, what would I have to do in order > to get a D compiler with my changes? [...] This might help: http

How to compile my DMD fork?

2019-06-14 Thread Q. Schroll via Digitalmars-d-learn
Basically the headline. I want to try to implement my DIP. I've already forked DMD from GitHub. Now, what would I have to do in order to get a D compiler with my changes? I have Windows on x86-64 and Visual Studio on my machine.

Re: Scope exit bug?

2019-06-14 Thread Les De Ridder via Digitalmars-d-learn
On Friday, 14 June 2019 at 05:35:05 UTC, Amex wrote: I used it to avoid having to write bar twice or use a flag but it's not working... I see no reason why it should not work. scope(exit) is suppose to execute the block at the end of the function call, right? No, a scope guard executes at the

Re: Proper desctructor for an class containing dynamic array of objects

2019-06-14 Thread XavierAP via Digitalmars-d-learn
On Friday, 14 June 2019 at 11:10:58 UTC, rumbu wrote: On Friday, 14 June 2019 at 07:52:24 UTC, Marco de Wild wrote: On Thursday, 13 June 2019 at 16:08:52 UTC, Mike wrote: Opposed to Java, D's member variables are static initialised. Is there any documentation about this? I find it unexpected.

Re: Proper desctructor for an class containing dynamic array of objects

2019-06-14 Thread rumbu via Digitalmars-d-learn
On Friday, 14 June 2019 at 07:52:24 UTC, Marco de Wild wrote: On Thursday, 13 June 2019 at 16:08:52 UTC, Mike wrote: Opposed to Java, D's member variables are static initialised. Is there any documentation about this? I find it unexpected.

Blog Post #0044 - File Dialog X - Custom Dialogs (3 of 3)

2019-06-14 Thread Ron Tarrant via Digitalmars-d-learn
Today sees the last of the mini-series on custom Dialog windows wherein we combine everything from the first two articles together into one final *Dialog*. You can find it here: http://gtkdcoding.com/2019/06/14/0044-custom-dialog-iii.html

Re: Elegant way to test if members of array A are present in array B?

2019-06-14 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-06-12 13:58:49 +, Meta said: There are two versions of find that can find a range within another: https://dlang.org/phobos/std_algorithm_searching.html#.find https://dlang.org/phobos/std_algorithm_searching.html#.find.3 Thanks, that looks good. I read the find docs, but somehow di

How to force D GC to deallocate everything?

2019-06-14 Thread Clipsey via Digitalmars-d-learn
I have written an DLL in D which gets used by an application (written in C) When the C code tries to deallocate/close the DLL, the C application freezes and/or leaks memory. My profiling using AMD µProf tells me that the D DLL never gets closed, my guess is that the D GC never deallocates ever

Re: Proper desctructor for an class containing dynamic array of objects

2019-06-14 Thread Marco de Wild via Digitalmars-d-learn
On Thursday, 13 June 2019 at 16:08:52 UTC, Mike wrote: Hi, my name is Mike and I'm new to D (coming from a Javabackground) and for fun I'm trying to learn D now. I created a simple class class Block { int a, b; this() {} } And now I have a dynamic array of objects of this class in