Re: What's wrong with this code?

2015-09-19 Thread Chris via Digitalmars-d-learn
On Saturday, 19 September 2015 at 02:45:54 UTC, Adam D. Ruppe wrote: On Saturday, 19 September 2015 at 02:30:39 UTC, Chris wrote: bmove.addOnClicked (delegate void (Button aux) { What's the context of this call? If it is inside a struct and you are accessing local

Re: What's wrong with this code?

2015-09-19 Thread Chris via Digitalmars-d-learn
Update: If I add *also* a auto vec2 = vec; now the code works. So it looks like this now: voxel_vec [string] move_buttons = [ "button_xp" : voxel_vec ([ 1, 0, 0 ]), "button_xm" : voxel_vec ([ -1, 0, 0 ]),

Re: What's wrong with this code?

2015-09-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 19 September 2015 at 02:30:39 UTC, Chris wrote: bmove.addOnClicked (delegate void (Button aux) { What's the context of this call? If it is inside a struct and you are accessing local variables you can get in trouble because the context pointer may not be

Re: What's wrong with this code?

2011-01-10 Thread Steven Schveighoffer
On Sat, 08 Jan 2011 15:46:01 -0500, Michal Minich michal.min...@gmail.com wrote: On Sat, 08 Jan 2011 20:34:39 +, Sean Eskapp wrote: if(left == null) 1) write if (left is null) instead if checking for null. Equality operator is rewritten to a.opEquals(b), which you

Re: What's wrong with this code?

2011-01-08 Thread Michal Minich
On Sat, 08 Jan 2011 20:34:39 +, Sean Eskapp wrote: if(left == null) 1) write if (left is null) instead if checking for null. Equality operator is rewritten to a.opEquals(b), which you don't want if you checking for null. this() { left = right = null; } 2) default

Re: What's wrong with this code?

2011-01-08 Thread Tomek Sowiński
Sean Eskapp napisał(a): I had some code that was segfaulting, so I rewrote the basic idea as a fibonacci function, and lo and behold, it still segfaults. Why, and how to fix? This looks fishy: class Fib { private const Fib* left, right; ... this(in Fib left, in Fib right)

Re: What's wrong with this code? (OP)

2011-01-08 Thread Sean Eskapp
Tomek got it right. Fixed by copying the objects, rather than using pointers. Thanks!