Re: cannot access frame of function

2017-09-18 Thread Alex via Digitalmars-d-learn
On Monday, 18 September 2017 at 18:49:54 UTC, ag0aep6g wrote: Doesn't work for me. This still fails compilation with the same error: import std.algorithm.iteration : sum, cumulativeFold; void main() { double[5] a; auto asum = 1.23; auto jProbs = a[].cumulativeFold!((a, b) =>

Re: scope(exit) and destructor prioity

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 18 September 2017 at 20:55:21 UTC, Sasszem wrote: If I write "auto a = new De()", then it calls the scope first, no matter where I place it. Because with `new` a) your struct object is located on the heap (and referred to by pointer - `De*`) instead of the stack (which means no

Re: scope(exit) and destructor prioity

2017-09-18 Thread Eugene Wissner via Digitalmars-d-learn
On Monday, 18 September 2017 at 20:55:21 UTC, Sasszem wrote: On Monday, 18 September 2017 at 20:30:20 UTC, Jerry wrote: On Monday, 18 September 2017 at 20:26:05 UTC, Sasszem wrote: [...] It's called inbetween the destructors of wherever you put the scope(exit). import std.stdio; struct

Re: scope(exit) and destructor prioity

2017-09-18 Thread Sasszem via Digitalmars-d-learn
On Monday, 18 September 2017 at 20:30:20 UTC, Jerry wrote: On Monday, 18 September 2017 at 20:26:05 UTC, Sasszem wrote: [...] It's called inbetween the destructors of wherever you put the scope(exit). import std.stdio; struct De { ~this() { writeln("De"); } } void main() {

Re: scope(exit) and destructor prioity

2017-09-18 Thread Jerry via Digitalmars-d-learn
On Monday, 18 September 2017 at 20:26:05 UTC, Sasszem wrote: I'm currently working on a project and for that I've created a thin OO-wrapper on top of derelict-sdl. However, when I close my app, the program terminates with a segfault. I've managed to track down the source, and found that the

scope(exit) and destructor prioity

2017-09-18 Thread Sasszem via Digitalmars-d-learn
I'm currently working on a project and for that I've created a thin OO-wrapper on top of derelict-sdl. However, when I close my app, the program terminates with a segfault. I've managed to track down the source, and found that the destructors of my objects are called AFTER the scope(exit)

Re: cannot access frame of function

2017-09-18 Thread user1234 via Digitalmars-d-learn
On Monday, 18 September 2017 at 18:49:54 UTC, ag0aep6g wrote: On 09/18/2017 08:25 PM, user1234 wrote: On Monday, 18 September 2017 at 14:45:25 UTC, Alex wrote: [...] import std.algorithm.iteration : sum, cumulativeFold; void main() { double[5] a; [...]>> auto asum = a[].sum; [...]

Re: Looking for instructions on how to make a Derelict library

2017-09-18 Thread Matt Jones via Digitalmars-d-learn
On Monday, 18 September 2017 at 11:27:01 UTC, jmh530 wrote: On Monday, 18 September 2017 at 00:33:25 UTC, Matt Jones wrote: I've been reading the DerelictSDL2 source code. I think I have a handle on it. I'll have to look more at the wiki too. Thanks. Might be interesting to write up

Re: cannot access frame of function

2017-09-18 Thread ag0aep6g via Digitalmars-d-learn
On 09/18/2017 08:25 PM, user1234 wrote: On Monday, 18 September 2017 at 14:45:25 UTC, Alex wrote: [...] import std.algorithm.iteration : sum, cumulativeFold; void main() { double[5] a; [...]>> auto asum = a[].sum; [...] asum is a lazy range and the error comes from this. asum is

Re: cannot access frame of function

2017-09-18 Thread user1234 via Digitalmars-d-learn
On Monday, 18 September 2017 at 14:45:25 UTC, Alex wrote: Hi all, given this code: import std.algorithm.iteration : sum, cumulativeFold; void main() { double[5] a; a = 0; foreach(el; a) assert(el == 0); a[0] = 1.0; a[1] = 2.0; a[2] = 3.0;

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread SrMordred via Digitalmars-d-learn
void main() { auto s = S(); s["b", "c"] = s["a"]; } Prints a ["b", "c"] Ali I thought about this too, thanks!

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread Ali Çehreli via Digitalmars-d-learn
Have you considered the multiple indexes? https://dlang.org/spec/operatoroverloading.html#index_assignment_operator It may give you some power in execution order. import std.stdio; struct S { auto opIndex(string index) { writeln(index); return 42; } auto

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread SrMordred via Digitalmars-d-learn
On Monday, 18 September 2017 at 15:14:20 UTC, Moritz Maxeiner wrote: On Monday, 18 September 2017 at 15:11:34 UTC, Moritz Maxeiner wrote: gets rewritten to --- t.opIndex("b").opIndexAssign(t["a"].value, "c"); --- Sorry, forgot one level of rewriting: ---

Re: My friend can't install DMD 2.076.0 after he deleted contents of C:\D

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 17 September 2017 at 05:33:12 UTC, rikki cattermole wrote: Skip Revo-Uninstaller, no idea why you'd ever use such trial software. Anyway what you want is CCleaner, standard software that all Windows installs should have on hand.

Re: My friend can't install DMD 2.076.0 after he deleted contents of C:\D

2017-09-18 Thread Andre Kostur via Digitalmars-d-learn
On 2017-09-16 10:33 PM, rikki cattermole wrote: On 17/09/2017 6:30 AM, Enjoys Math wrote: Series of messages from installer: DMD v2.076.0 is installed on your system Press 'OK' to replace by DMD 2.076.0 An error occurred when removing DMD v2.076.0 Run 'dmd-2.076.0.exe /f to force install And

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 18 September 2017 at 15:11:34 UTC, Moritz Maxeiner wrote: gets rewritten to --- t.opIndex("b").opIndexAssign(t["a"].value, "c"); --- Sorry, forgot one level of rewriting: --- t.opIndex("b").opIndexAssign(t.opIndex("a").value, "c"); ---

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 17 September 2017 at 18:52:39 UTC, SrMordred wrote: struct Test{ [...] } Test t; As described in the spec [1] t["a"] = 100; gets rewritten to --- t.opIndexAssign(100, "a"); --- , while t["b"]["c"] = t["a"].value; gets rewritten to ---

cannot access frame of function

2017-09-18 Thread Alex via Digitalmars-d-learn
Hi all, given this code: import std.algorithm.iteration : sum, cumulativeFold; void main() { double[5] a; a = 0; foreach(el; a) assert(el == 0); a[0] = 1.0; a[1] = 2.0; a[2] = 3.0; a[3] = 4.0; a[4] = 5.0; foreach(el; a)

Re: Looking for instructions on how to make a Derelict library

2017-09-18 Thread SrMordred via Digitalmars-d-learn
I used to have a guide to creating "Derelictified" bindings for an older version. I should write one up for the current version. +1

Re: Looking for instructions on how to make a Derelict library

2017-09-18 Thread Mike Parker via Digitalmars-d-learn
On Monday, 18 September 2017 at 11:27:01 UTC, jmh530 wrote: On Monday, 18 September 2017 at 00:33:25 UTC, Matt Jones wrote: I've been reading the DerelictSDL2 source code. I think I have a handle on it. I'll have to look more at the wiki too. Thanks. Might be interesting to write up

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread SrMordred via Digitalmars-d-learn
Should I report this as a bug? I tried a C++ equivalent code and it execute in the expected order.

Re: Question on Container Array.

2017-09-18 Thread Eugene Wissner via Digitalmars-d-learn
On Monday, 18 September 2017 at 11:47:07 UTC, Vino.B wrote: Hi All, Can some one explain me on the below question. Q1: void main (Array!string args) : Why can't we use container array in void main? Q2: What is the difference between the below? insert, insertBack stableInsert,

Question on Container Array.

2017-09-18 Thread Vino.B via Digitalmars-d-learn
Hi All, Can some one explain me on the below question. Q1: void main (Array!string args) : Why can't we use container array in void main? Q2: What is the difference between the below? insert, insertBack stableInsert, stableInsertBack linearInsert, stableLinearInsert, stableLinearInsert

Re: Looking for instructions on how to make a Derelict library

2017-09-18 Thread jmh530 via Digitalmars-d-learn
On Monday, 18 September 2017 at 00:33:25 UTC, Matt Jones wrote: I've been reading the DerelictSDL2 source code. I think I have a handle on it. I'll have to look more at the wiki too. Thanks. Might be interesting to write up your experience with doing it as either blog post or part of

Re: extern(C) enum

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 18 September 2017 at 02:04:49 UTC, bitwise wrote: The following code will run fine on Windows, but crash on iOS due to the misaligned access: Interesting, does iOS crash such a process intentionally, or is it a side effect? char data[8]; int i = 0x; int* p =