Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread MarisaLovesUsAll via Digitalmars-d-learn
No need. Message has additional arguments. Btw, thanks for help! I found a solution. struct Message { uint id; string command; Variant[] args; this(T...)(uint id, string command, T args) { this.id = id; this.command = command; this.args = variantArray

Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread MarisaLovesUsAll via Digitalmars-d-learn
Thanks for reply. Strings are immutable so thats ok. A class instance that isn't immutable isn't. It's not a class instance, it's a class type. Something like `cast(Sprite) null` in parameters. It can be replaced by string "Sprite", but in this case I can't use receive() as it is. E.g. send

How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread MarisaLovesUsAll via Digitalmars-d-learn
Hi! I'm trying to make my program multithreaded, and I was stuck at messaging between threads. I need to pack types and variables into one message. Will I use Tuples or something? e.g. class Sprite {}; send(tid, Sprite, "create", myInt); Also I don't understand how to use

Re: How to compare two types?

2014-09-01 Thread MarisaLovesUsAll via Digitalmars-d-learn
Thanks for the answers!

How to compare two types?

2014-08-31 Thread MarisaLovesUsAll via Digitalmars-d-learn
How to compare two types? Will I use T.stringof instead of this? void main() { if(One is Two) {} //Error: type One is not an expression //Error: type Two is not an expression } class One {} class Two {} Regards, MarisaLovesUsAll

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread MarisaLovesUsAll via Digitalmars-d-learn
On Thursday, 21 August 2014 at 20:16:33 UTC, anonymous wrote: Maybe you can explain what you're trying to achieve with all this. There may be a different/better way to do it. Sure. Class tree: GameObject->Component->Sprite. GameObject structure: Component[]; Component addComponent(Compo

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread MarisaLovesUsAll via Digitalmars-d-learn
On Thursday, 21 August 2014 at 13:19:06 UTC, anonymous wrote: 1) How to make mixin inject automatic? You could use this pattern: interface Component {} class ComponentImpl(T) {} class Sprite : ComponentImpl!Sprite {} From my view, it's an architectural crutch. %) You can use `typeof(this)`

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread MarisaLovesUsAll via Digitalmars-d-learn
I found a rough solution. It's not ideal and I still want to make autoinject, but it works. mixin template Manager(T) {}; class Component {}; class Sprite:Component { mixin Manager!Sprite; }; 1) How to make mixin inject automatic? 2) If it's impossible, how to use "mixin Manager;" without

Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread MarisaLovesUsAll via Digitalmars-d-learn
tl;dr - how to get child classname from inherited parent function at compile time? class A { string getName(); }; class B { }; B foo = new B; assert(foo.getName() == "B"); ... Hi! I'm stuck at one issue, and I don't know how to solve it. I think this is about mixins/templates, isn't it? When in

Temporary silence output (stdout)

2014-05-10 Thread MarisaLovesUsAll via Digitalmars-d-learn
Hi! I sometimes got a useless messages in stdout from SDL_Image library, and I want to temporary silence it. How do I do?