store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
I have a class that creates a task in it's constructor. How do I store this created task as one of it's value members and later on call .yieldForce()?

Re: Import template in phobos

2015-08-01 Thread BBasile via Digitalmars-d-learn
On Saturday, 1 August 2015 at 14:42:47 UTC, vit wrote: Exist in phobos something like Import template? public import std.traits; template Import(alias Module){ mixin(import ~ moduleName!Module ~ ;); } class C; struct Test{ Import!(std.typecons).Rebindable!C test;

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread BBasile via Digitalmars-d-learn
On Saturday, 1 August 2015 at 17:22:40 UTC, NX wrote: I wonder if the followings are compiler bugs: class stuff_class { byte[1024*1024*16] arr; // Error: index 16777216 overflow for static array } struct stuff { byte[1024*1024*16] arr; // Error: index 16777216 overflow for static

Re: Array start index

2015-08-01 Thread John Colvin via Digitalmars-d-learn
On Saturday, 1 August 2015 at 09:35:53 UTC, DLearner wrote: Does the D language set in stone that the first element of an array _has_ to be index zero? For the builtin slice types? Yes, set in stone. Wouldn't starting array elements at one avoid the common 'off-by-one' logic error, it does

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread NX via Digitalmars-d-learn
Typo: *scenario

Re: store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
But it's std.parallelism's task... And how can I use get!T if I don't know the type of the task? 2015-08-01 19:02 GMT+02:00 Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn@puremagic.com: On Saturday, 1 August 2015 at 16:41:54 UTC, maarten van damme wrote: I was afraid I would have

Static arrays inside struct and class - bug?

2015-08-01 Thread NX via Digitalmars-d-learn
I wonder if the followings are compiler bugs: class stuff_class { byte[1024*1024*16] arr; // Error: index 16777216 overflow for static array } struct stuff { byte[1024*1024*16] arr; // Error: index 16777216 overflow for static array } My project has just stopped for this reason, I

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread NX via Digitalmars-d-learn
On Saturday, 1 August 2015 at 17:29:54 UTC, Adam D. Ruppe wrote: On Saturday, 1 August 2015 at 17:22:40 UTC, NX wrote: I wonder if the followings are compiler bugs: No, it is by design, the idea is to keep static arrays smallish so null references will be caught by the processor. (An overly

Re: store template value

2015-08-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 1 August 2015 at 16:41:54 UTC, maarten van damme wrote: I was afraid I would have to do that. Templatizing the class on the value doesn't work as I later on want to create a hashmap of these classes. When I assign a task to a variant, how do I call .yieldForce later on? You can

Re: Struct that destroys its original handle on copy-by-value

2015-08-01 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 31/07/15 19:21, Ali Çehreli via Digitalmars-d-learn wrote: On 07/26/2015 04:29 AM, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: is this design idea even feasible in principle, or just a bad idea from the get-go? As I understand it, it is against one of fundamental D

Import template in phobos

2015-08-01 Thread vit via Digitalmars-d-learn
Exist in phobos something like Import template? public import std.traits; template Import(alias Module){ mixin(import ~ moduleName!Module ~ ;); } class C; struct Test{ Import!(std.typecons).Rebindable!C test;//symbols }

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 1 August 2015 at 17:22:40 UTC, NX wrote: I wonder if the followings are compiler bugs: No, it is by design, the idea is to keep static arrays smallish so null references will be caught by the processor. (An overly large static array could allow indexing it through a null pointer

Re: Struct that destroys its original handle on copy-by-value

2015-08-01 Thread John Colvin via Digitalmars-d-learn
On Saturday, 1 August 2015 at 12:10:43 UTC, Joseph Rushton Wakeling wrote: On 31/07/15 19:21, Ali Çehreli via Digitalmars-d-learn wrote: On 07/26/2015 04:29 AM, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: is this design idea even feasible in principle, or just a bad idea from

Re: How disruptive is the GC?

2015-08-01 Thread ponce via Digitalmars-d-learn
On Wednesday, 29 July 2015 at 09:25:50 UTC, Snape wrote: I'm in the early stages of building a little game with OpenGL (in D) and I just want to know the facts about the GC before I decide to either use it or work around it. Lots of people have said lots of things about it, but some of that

Re: Struct that destroys its original handle on copy-by-value

2015-08-01 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 31/07/15 13:40, Kagamin via Digitalmars-d-learn wrote: On Sunday, 26 July 2015 at 12:16:30 UTC, Joseph Rushton Wakeling wrote: Example: Unique!Random rng = new Random(unpredictableSeed); rng.take(10).writeln; My aim by contrast is to _allow_ that kind of use, but render the original

Re: store template value

2015-08-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 1 August 2015 at 15:37:46 UTC, maarten van damme wrote: I have a class that creates a task in it's constructor. How do I store this created task as one of it's value members and later on call .yieldForce()? If the class itself isn't templated on the type, you'll want to use

Re: Import template in phobos

2015-08-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 1 August 2015 at 14:42:47 UTC, vit wrote: Exist in phobos something like Import template? What would you use that for? You can just use the import keyword...

Re: Array start index

2015-08-01 Thread bachmeier via Digitalmars-d-learn
On Saturday, 1 August 2015 at 09:35:53 UTC, DLearner wrote: Does the D language set in stone that the first element of an array _has_ to be index zero? Wouldn't starting array elements at one avoid the common 'off-by-one' logic error, it does seem more natural to begin a count at 1. Actually,

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 1 August 2015 at 18:07:51 UTC, NX wrote: Sorry, I can't see _the_ point in that. Yeah, especially since you can jsut break up the array and get the same effect anyway... so like if you don't want to dynamically allocate the memory, you could also try: byte[1024*1024*8]

Re: store template value

2015-08-01 Thread maarten van damme via Digitalmars-d-learn
I was afraid I would have to do that. Templatizing the class on the value doesn't work as I later on want to create a hashmap of these classes. When I assign a task to a variant, how do I call .yieldForce later on? 2015-08-01 18:28 GMT+02:00 Adam D. Ruppe via Digitalmars-d-learn

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread NX via Digitalmars-d-learn
On Saturday, 1 August 2015 at 18:47:00 UTC, Daniel Kozak wrote: Still same problem, You can`t allocate more then 16M on stack. Use dynamic allocation I don't think new MyStruct allocates on stack, actually allocating ~16MB on stack will immediatelly crash the program which is not the case

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 19:21:36 + NX via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Saturday, 1 August 2015 at 18:50:09 UTC, Daniel Kozak wrote: No you don't. You still use static allocation for array Can clarify why does that happen and I still suspect it's a

Re: alias overloading strange error

2015-08-01 Thread anonymous via Digitalmars-d-learn
On Friday, 31 July 2015 at 11:09:39 UTC, anonymous wrote: Definitely a bug. Please file an issue at https://issues.dlang.org/. https://issues.dlang.org/show_bug.cgi?id=14858

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
On Saturday, 1 August 2015 at 18:07:51 UTC, NX wrote: On Saturday, 1 August 2015 at 17:29:54 UTC, Adam D. Ruppe wrote: Sorry, I can't see _the_ point in that. I understand that could be a problem if it was a global array but this scenery is completely wrong in my view. I'm already going to

How to run opengl tutorials

2015-08-01 Thread nikolai via Digitalmars-d-learn
Hey, I have found this great source of tutorials for simple game development, yet i am unable to run it properly on Windows 8.1. https://github.com/d-gamedev-team/opengl-tutorials/tree/master/ports/opengl-tutorial.org/tutorials/01_window Can someone tell me how can i run all those examples? I

Re: Array start index

2015-08-01 Thread DLearner via Digitalmars-d-learn
On Saturday, 1 August 2015 at 17:55:06 UTC, John Colvin wrote: On Saturday, 1 August 2015 at 09:35:53 UTC, DLearner wrote: Does the D language set in stone that the first element of an array _has_ to be index zero? For the builtin slice types? Yes, set in stone. Wouldn't starting array

Re: Array start index

2015-08-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 8/1/15, DLearner via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D is a C derivative, so it seems a shame not to identify causes of bugs in C, and design them out in D. This has already been done! D defines an array to be a struct with a pointer and a length. See this

Re: extern(C) with function returning user type

2015-08-01 Thread Kyoji Klyden via Digitalmars-d-learn
On Saturday, 1 August 2015 at 04:11:02 UTC, Laeeth Isharc wrote: Walter observes that if you are a Java programmer and start writing D, you will write D like you write Java. And so I suppose one will see what one doesn't have in Java, but not so much the benefits of D. That's true of other

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread NX via Digitalmars-d-learn
On Saturday, 1 August 2015 at 18:50:09 UTC, Daniel Kozak wrote: No you don't. You still use static allocation for array Can clarify why does that happen and I still suspect it's a static allocation it would increase output exe if it was really that static..?

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 19:16:16 + NX via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Saturday, 1 August 2015 at 18:47:00 UTC, Daniel Kozak wrote: Still same problem, You can`t allocate more then 16M on stack. Use dynamic allocation I don't think new MyStruct

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread NX via Digitalmars-d-learn
On Saturday, 1 August 2015 at 19:33:26 UTC, Daniel Kozak wrote: My fault It is not on stack, but still it is a static allocation I think you're misusing static allocation and static declaration for each other.

Re: Array start index

2015-08-01 Thread bachmeier via Digitalmars-d-learn
On Saturday, 1 August 2015 at 19:04:10 UTC, Andrej Mitrovic wrote: On 8/1/15, DLearner via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D is a C derivative, so it seems a shame not to identify causes of bugs in C, and design them out in D. This has already been done! D defines

Re: store template value

2015-08-01 Thread Ali Çehreli via Digitalmars-d-learn
On 08/01/2015 08:37 AM, maarten van damme via Digitalmars-d-learn wrote: I have a class that creates a task in it's constructor. How do I store this created task as one of it's value members and later on call .yieldForce()? Tasks can be created with a function pointer 'function parameter' as

Re: How to run opengl tutorials

2015-08-01 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 1 August 2015 at 22:14:45 UTC, nikolai wrote: Hey, I have found this great source of tutorials for simple game development, yet i am unable to run it properly on Windows 8.1.

Re: Struct that destroys its original handle on copy-by-value

2015-08-01 Thread Dicebot via Digitalmars-d-learn
On Saturday, 1 August 2015 at 17:50:28 UTC, John Colvin wrote: I'm not sure how good an idea it is to totally enforce a range to be non-copyable, even if you could deal with the function call chain problem. Even in totally save-aware code, there can still be valid assignment of a range type.

Re: Static arrays inside struct and class - bug?

2015-08-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sat, 01 Aug 2015 18:07:50 + NX via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Saturday, 1 August 2015 at 17:29:54 UTC, Adam D. Ruppe wrote: On Saturday, 1 August 2015 at 17:22:40 UTC, NX wrote: I wonder if the followings are compiler bugs: No, it is by

Array start index

2015-08-01 Thread DLearner via Digitalmars-d-learn
Does the D language set in stone that the first element of an array _has_ to be index zero? Wouldn't starting array elements at one avoid the common 'off-by-one' logic error, it does seem more natural to begin a count at 1. Actually, maybe even better to allow array definitions of form int

Re: Array start index

2015-08-01 Thread Rikki Cattermole via Digitalmars-d-learn
On 1/08/2015 9:35 p.m., DLearner wrote: Does the D language set in stone that the first element of an array _has_ to be index zero? Wouldn't starting array elements at one avoid the common 'off-by-one' logic error, it does seem more natural to begin a count at 1. Actually, maybe even better to