Re: Odd Destructor Behavior

2016-02-07 Thread Daniel Kozak via Digitalmars-d-learn
V Sun, 07 Feb 2016 23:47:39 + Matt Elkins via Digitalmars-d-learn napsáno: > On Sunday, 7 February 2016 at 23:11:34 UTC, anonymous wrote: > > On 07.02.2016 23:49, Matt Elkins wrote: > >> Oi. Yes, I can, but it is quite a lot of code even if you > >>

Re: Things that keep D from evolving?

2016-02-07 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Sunday, 7 February 2016 at 02:46:39 UTC, Marco Leise wrote: My code would not see much ref counting in performance critical loops. There is no point in ref counting every single point in a complex 3D scene. I could imagine it used on bigger items. Textures for example since they may be used

Re: Detecting exception unwinding

2016-02-07 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 6 February 2016 at 22:51:45 UTC, cy wrote: auto e = somethingThatFails() scope(failure) cleanup(e); makes more sense to me, since it's blatantly obvious that the construction (and entering) process isn't covered by the cleanup routine. Not sure what you mean by that.

Re: Cannot get Derelict to work

2016-02-07 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 7 February 2016 at 12:55:30 UTC, Whirlpool wrote: Is it the same kind of problem as before ? If my understanding is correct [1], I need to link with the OpenGL DLL, don't I ? I found that I have an opengl32.dll file in C:\Windows\System32, and tried adding the path to it in the

Re: Cannot get Derelict to work

2016-02-07 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 7 February 2016 at 14:04:49 UTC, Mike Parker wrote: Another point to make is that if you need deprecated functions, DerelictGL3 is not what you want. You should import derelict.opengl3.gl and use DerelictGL.load/reload instead. It includes all of the deprecated functions. Just

Re: Cannot get Derelict to work

2016-02-07 Thread Whirlpool via Digitalmars-d-learn
Hi, Sorry, I have a problem again :) I tried to compile this example : http://www.glfw.org/docs/latest/quick.html#quick_example which required to add derelict-gl3 My code is currently this : http://pastebin.com/A5seZmX6 It compiles without errors, but crashes immediately with again

Re: Overloading free functions & run-time dispatch based on parameter types

2016-02-07 Thread Robert M. Münch via Digitalmars-d-learn
On 2016-02-06 14:33:57 +, Marc Schütz said: I don't see why this wouldn't work, if you've in fact covered all combinations. It works, the problem was that castSwitch returns something and I didn't "catch" it. It's similar to how castSwitch is implemented, though the double casts are

Re: Bug or intended?

2016-02-07 Thread Marc Schütz via Digitalmars-d-learn
The specification doesn't list (non-static) members a valid template alias parameters: http://dlang.org/spec/template.html#TemplateAliasParameter

Re: is increment on shared ulong atomic operation?

2016-02-07 Thread Minas Mina via Digitalmars-d-learn
On Sunday, 7 February 2016 at 19:43:23 UTC, rsw0x wrote: On Sunday, 7 February 2016 at 19:39:27 UTC, rsw0x wrote: On Sunday, 7 February 2016 at 19:27:19 UTC, Charles Hixson wrote: If I define a shared ulong variable, is increment an atomic operation? E.g. shared ulong t; ... t++; It seems

Re: Odd Destructor Behavior

2016-02-07 Thread Márcio Martins via Digitalmars-d-learn
On Sunday, 7 February 2016 at 21:49:24 UTC, Matt Elkins wrote: I've been experiencing some odd behavior, where it would appear that a struct's destructor is being called before the object's lifetime expires. More likely I am misunderstanding something about the lifetime rules for structs. I

Re: is increment on shared ulong atomic operation?

2016-02-07 Thread rsw0x via Digitalmars-d-learn
On Sunday, 7 February 2016 at 19:27:19 UTC, Charles Hixson wrote: If I define a shared ulong variable, is increment an atomic operation? E.g. shared ulong t; ... t++; It seems as if it ought to be, but it could be split into read, increment, store. I started off defining a shared struct,

Re: is increment on shared ulong atomic operation?

2016-02-07 Thread rsw0x via Digitalmars-d-learn
On Sunday, 7 February 2016 at 20:25:44 UTC, Minas Mina wrote: On Sunday, 7 February 2016 at 19:43:23 UTC, rsw0x wrote: On Sunday, 7 February 2016 at 19:39:27 UTC, rsw0x wrote: On Sunday, 7 February 2016 at 19:27:19 UTC, Charles Hixson wrote: [...]

Odd Destructor Behavior

2016-02-07 Thread Matt Elkins via Digitalmars-d-learn
I've been experiencing some odd behavior, where it would appear that a struct's destructor is being called before the object's lifetime expires. More likely I am misunderstanding something about the lifetime rules for structs. I haven't been able to reproduce with a particularly minimal

Re: Odd Destructor Behavior

2016-02-07 Thread Matt Elkins via Digitalmars-d-learn
On Sunday, 7 February 2016 at 22:35:57 UTC, anonymous wrote: On 07.02.2016 23:07, Márcio Martins wrote: The destructor you are seeing is from the assignment: m_tileView = TileView(...); This creates a temporary TileView, copies it to m_tileView, and then destroys it. I suppose you want to

Re: is increment on shared ulong atomic operation?

2016-02-07 Thread rsw0x via Digitalmars-d-learn
On Sunday, 7 February 2016 at 19:39:27 UTC, rsw0x wrote: On Sunday, 7 February 2016 at 19:27:19 UTC, Charles Hixson wrote: If I define a shared ulong variable, is increment an atomic operation? E.g. shared ulong t; ... t++; It seems as if it ought to be, but it could be split into read,

Re: Cannot get Derelict to work

2016-02-07 Thread Whirlpool via Digitalmars-d-learn
Thank you very much for your explanations and patience :) I indeed have an AMD Radeon HD 7870 card, and using 4.4 as the max version fixes my problem !

Re: Odd Destructor Behavior

2016-02-07 Thread anonymous via Digitalmars-d-learn
On 07.02.2016 22:49, Matt Elkins wrote: From this non-reduced situation, does anything jump out? Am I missing something about struct lifetimes? This is the only place I instantiate a TileView. Looks weird. I presume this doesn't happen with simpler constructor parameters/arguments, like int

Re: Odd Destructor Behavior

2016-02-07 Thread anonymous via Digitalmars-d-learn
On 07.02.2016 23:07, Márcio Martins wrote: The destructor you are seeing is from the assignment: m_tileView = TileView(...); This creates a temporary TileView, copies it to m_tileView, and then destroys it. I suppose you want to move it instead. You need to copy the handles from the temporary

Re: Odd Destructor Behavior

2016-02-07 Thread Matt Elkins via Digitalmars-d-learn
On Sunday, 7 February 2016 at 22:04:27 UTC, anonymous wrote: On 07.02.2016 22:49, Matt Elkins wrote: From this non-reduced situation, does anything jump out? Am I missing something about struct lifetimes? This is the only place I instantiate a TileView. Looks weird. I presume this doesn't

is increment on shared ulong atomic operation?

2016-02-07 Thread Charles Hixson via Digitalmars-d-learn
If I define a shared ulong variable, is increment an atomic operation? E.g. shared ulong t; ... t++; It seems as if it ought to be, but it could be split into read, increment, store. I started off defining a shared struct, but that seems silly, as if the operations defined within a shared

Re: Odd Destructor Behavior

2016-02-07 Thread anonymous via Digitalmars-d-learn
On 07.02.2016 23:49, Matt Elkins wrote: Oi. Yes, I can, but it is quite a lot of code even if you don't count that it is dependent on OpenGL, GLFW, and gl3n to run to this point. This is why I was disappointed that simpler reproducing cases weren't appearing. I should probably spend more time

Re: Odd Destructor Behavior

2016-02-07 Thread Matt Elkins via Digitalmars-d-learn
On Sunday, 7 February 2016 at 23:11:34 UTC, anonymous wrote: On 07.02.2016 23:49, Matt Elkins wrote: Oi. Yes, I can, but it is quite a lot of code even if you don't count that it is dependent on OpenGL, GLFW, and gl3n to run to this point. This is why I was disappointed that simpler

Re: Odd Destructor Behavior

2016-02-07 Thread Matt Elkins via Digitalmars-d-learn
Some environment information: DMD 2.070 32-bit Windows 7 (64-bit)

What is a short, fast way of testing whether x in [a, b]?

2016-02-07 Thread Enjoys Math via Digitalmars-d-learn
Right now I'm using a logical ||: if (!(2*PI - EPS!float <= t1-t0 || t1-t0 <= 2*PI + EPS!float)) { But I'll be doing this a lot, so was wondering if there's a D native way of doing it. Thanks.

Re: is increment on shared ulong atomic operation?

2016-02-07 Thread Charles Hixson via Digitalmars-d-learn
Thanks, that's what I needed to know. I'm still going to do it as a class, but now only the inc routine needs to be handled specially. (The class is so that other places where the value is used don't even need to know that it's special. And so that instances are easy to share between

Re: What is a short, fast way of testing whether x in [a, b]?

2016-02-07 Thread Enjoys Math via Digitalmars-d-learn
On Monday, 8 February 2016 at 02:47:24 UTC, Enjoys Math wrote: Right now I'm using a logical ||: if (!(2*PI - EPS!float <= t1-t0 || t1-t0 <= 2*PI + EPS!float)) { But I'll be doing this a lot, so was wondering if there's a D native way of doing it. Thanks. Currently I have: @property T

Re: What is a short, fast way of testing whether x in [a, b]?

2016-02-07 Thread cy via Digitalmars-d-learn
On Monday, 8 February 2016 at 03:09:53 UTC, Enjoys Math wrote: was wondering if there's a D native way of doing it. That is the D native way of doing it, but you could clean up a lot of the boilerplate with some more templates. Also, || tests for exclusion, as in whether something is NOT in

How do you pass in a static array by reference?

2016-02-07 Thread Enjoys Math via Digitalmars-d-learn
I have several class members: Arc[4] arcs; Arc[4] arcs_2; and Id like to initialize them with the same function, so how do I "pass them in" by reference?

Re: How do you pass in a static array by reference?

2016-02-07 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 8 February 2016 at 05:59:43 UTC, Enjoys Math wrote: I have several class members: Arc[4] arcs; Arc[4] arcs_2; and Id like to initialize them with the same function, so how do I "pass them in" by reference? void foo(ref Arc[4] arr) { … } The dimension can of course be

Re: How do you pass in a static array by reference?

2016-02-07 Thread Jakob Ovrum via Digitalmars-d-learn
On Monday, 8 February 2016 at 06:01:24 UTC, Jakob Ovrum wrote: On Monday, 8 February 2016 at 05:59:43 UTC, Enjoys Math wrote: I have several class members: Arc[4] arcs; Arc[4] arcs_2; and Id like to initialize them with the same function, so how do I "pass them in" by reference? void

Re: Dynamic Ctors ?

2016-02-07 Thread Voitech via Digitalmars-d-learn
On Saturday, 6 February 2016 at 23:35:17 UTC, Ali Çehreli wrote: On 02/06/2016 10:05 AM, Voitech wrote: > [...] You can use string mixins (makeCtor and makeCtors): string makeCtor(T)() { import std.string : format; [...] Thank you very much for answering. Cheers