Template unique IDs per type

2013-07-11 Thread Roderick Gibson
I was recently looking up how to assign a unique ID based on each different implementation of a templated type (NOT per instance, but per unique type). For example: class MyTemplate(T) { //the ? where the actual number would go const int type_id = ?; } void main() { auto a = new

Re: Template unique IDs per type

2013-07-11 Thread Roderick Gibson
On Friday, 12 July 2013 at 03:56:50 UTC, JS wrote: sure, each type name is unique. All you have to do is convert them to an int... use a hash or some other method or just use the string names. If you need the id's to be continuous try to use an set(array) of the type names. Not sure if the

Re: Template unique IDs per type

2013-07-11 Thread Roderick Gibson
On Friday, 12 July 2013 at 04:42:28 UTC, Jonathan M Davis wrote: On Friday, July 12, 2013 05:15:43 Roderick Gibson wrote: I was recently looking up how to assign a unique ID based on each different implementation of a templated type (NOT per instance, but per unique type). For example: class

Re: Template unique IDs per type

2013-07-11 Thread Roderick Gibson
On Friday, 12 July 2013 at 04:42:28 UTC, Jonathan M Davis wrote: Now, it's probably possible to use static constructors to use global mutable state to intialize all of those IDs when the program starts up, which would initialize the IDs to incrementing values, so they could be immutable if you

Re: Handling different types gracefully

2013-07-02 Thread Roderick Gibson
On Tuesday, 2 July 2013 at 06:54:58 UTC, bearophile wrote: Roderick Gibson: Variant is a possiblity. How is the performance with large containers of these, since these structures will likely hold the majority of the data in the game? You probably have to benchmark yourself. (But I have

Re: Handling different types gracefully

2013-07-02 Thread Roderick Gibson
On Tuesday, 2 July 2013 at 21:45:57 UTC, bearophile wrote: Roderick Gibson: I should know the types at compile time, so I will be using it most likely, but reading the docs it looks like Algebraic is built on top of the same structure as Variant. Is there any difference in implementation

Handling different types gracefully

2013-07-01 Thread Roderick Gibson
I'm asking because I'm doing some game development in D and I've come upon the entity component architecture, and it looks like a good way to handle the complexity and interdependency that games seem to have. The components wind up being plain old data types (I currently use structs), with

Re: Handling different types gracefully

2013-07-01 Thread Roderick Gibson
On Monday, 1 July 2013 at 12:16:50 UTC, bearophile wrote: Roderick Gibson: auto entities = new Entities(); auto entity_id = entities.createEntity(); entities.addComponent!(position)(entity_id, pos); entities.addComponent!(movement)(entity_id, mov); entities.addComponent!(collision)(entity_id

Re: Direlect3 with Mono-D

2013-04-22 Thread Roderick Gibson
On Monday, 22 April 2013 at 20:57:56 UTC, Dementor561 wrote: On Monday, 22 April 2013 at 20:47:32 UTC, Minas Mina wrote: If you aren't comfortable with either C++ or D I would suggest to do the tutorials with C++, as there are no OpenGL tutorials for D. Don't try to learn two things at the

Re: Direlect3 with Mono-D

2013-04-21 Thread Roderick Gibson
On Sunday, 21 April 2013 at 15:21:00 UTC, Dementor561 wrote: On Saturday, 20 April 2013 at 22:25:42 UTC, Roderick Gibson wrote: On Saturday, 20 April 2013 at 15:49:47 UTC, Dementor561 wrote: I have all the needed files to use Direlect3, and I have Mono-D installed on Xamarin, I was wondering

Re: Direlect3 with Mono-D

2013-04-21 Thread Roderick Gibson
On Sunday, 21 April 2013 at 15:21:00 UTC, Dementor561 wrote: On Saturday, 20 April 2013 at 22:25:42 UTC, Roderick Gibson wrote: On Saturday, 20 April 2013 at 15:49:47 UTC, Dementor561 wrote: I have all the needed files to use Direlect3, and I have Mono-D installed on Xamarin, I was wondering

Re: Direlect3 with Mono-D

2013-04-21 Thread Roderick Gibson
On Sunday, 21 April 2013 at 19:49:14 UTC, Dementor561 wrote: Well, sorta. When I add import derelict.glfw3.glfw3; it says the library could not be resolved... Do I need to add something to the library somewhere? Any library you use you have to add to the project linker settings. Derelict3

Could use some help with porting problems

2012-02-07 Thread Roderick Gibson
So I needed a coherent noise generator and decided to look at libnoise. Noticing it was rather small I decided I would just port it over to d and be done with it, as I expected it would help me understand d a bit better (it has). My problems all seem to stem from the const qualifier, which is

Re: Could use some help with porting problems

2012-02-07 Thread Roderick Gibson
On 2/7/2012 7:58 PM, Daniel Murphy wrote: It seems the problem you've run into is that a class reference cannot be tail-const. Pointers can be tail-const like this: const(Data)* but there is no way currently (there are proposals) to make only the data and not the reference const. A workaround

Re: How convice people that D it's wonderfull in a hour ?

2011-10-09 Thread Roderick Gibson
On 10/9/2011 5:18 PM, deadalnix wrote: Le 09/10/2011 12:00, Zardoz a écrit : Recently I've been asked if I could give a speech about D in my university. It will be of one hour of long. I not respond yet, but I think that I will do it. Actually I have the problem that I don't know well how

Re: Is there a way to set an alias to specific form of a template?

2011-10-08 Thread Roderick Gibson
On 10/7/2011 7:33 PM, Andrej Mitrovic wrote: You don't have to rewrite Vector for multiple dimensions, methinks: class Vector(T...) { this(T t) {} } void main() { alias Vector!(float, float) vec2f; auto v = new vec2f(1.0,1.0); } You'll probably have to play with `static if`,

Re: Is there a way to set an alias to specific form of a template?

2011-10-08 Thread Roderick Gibson
On 10/7/2011 11:35 PM, Ali Çehreli wrote: On Fri, 07 Oct 2011 18:29:26 -0700, Roderick Gibson wrote: This may be the completely wrong approach, but I am basically thinking of something like this (I am aware this will not compile, it's psuedocode): class Vector(T) { ... //definition

Re: Simple I know, but could use some help compiling with make

2011-10-07 Thread Roderick Gibson
On 10/5/2011 7:46 AM, Ola Ost wrote: I had exactly this problem too, I asked on the Derelict forums: http://www.dsource.org/forums/viewtopic.php?t=5856sid=8ebff671fafec3bd8962ddfceaf99eb8 At the moment I've resolved this by building Derelict with make, first a normal full build, then a second

Is there a way to set an alias to specific form of a template?

2011-10-07 Thread Roderick Gibson
This may be the completely wrong approach, but I am basically thinking of something like this (I am aware this will not compile, it's psuedocode): class Vector(T) { ... //definition here } alias Vector(float, float) vec2f; auto v = new vec2f(1.0,1.0); I am making a templated Vector

Simple I know, but could use some help compiling with make

2011-09-29 Thread Roderick Gibson
It's my first foray into the arcana of makefiles and command line compiling. My makefile looks like this: IMPORT = -IC:\Dlang\dmd2\src\ext\Derelict2\import LIB_PATHS = -LC:\Dlang\dmd2\src\ext\Derelict2\lib LIB_INCLUDES = DerelictSDL.lib DerelictGL.lib DerelictUtil.lib all: dmd

Re: Simple I know, but could use some help compiling with make

2011-09-29 Thread Roderick Gibson
On 9/29/2011 2:15 PM, Nick Sabalausky wrote: Nick Sabalauskya@a.a wrote in message news:j62msu$205t$1...@digitalmars.com... Roderick Gibsonknit...@gmail.com wrote in message news:j62d4i$1d8l$1...@digitalmars.com... It's my first foray into the arcana of makefiles and command line compiling.

Re: Simple I know, but could use some help compiling with make

2011-09-29 Thread Roderick Gibson
On 9/29/2011 2:39 PM, Nick Sabalausky wrote: Roderick Gibsonknit...@gmail.com wrote in message news:j62nvo$2237$1...@digitalmars.com... On 9/29/2011 2:15 PM, Nick Sabalausky wrote: Nick Sabalauskya@a.a wrote in message news:j62msu$205t$1...@digitalmars.com... Roderick