Compile-time variables

Alex sascha.orlov at gmail.com
Fri Apr 6 11:42:32 UTC 2018


On Friday, 6 April 2018 at 02:20:29 UTC, Kayomn wrote:
>
> Wrong example code, here's the correct example:
> --------------------------------------------------------------------------------
> switch (queryString(childJson,"type")) {
> 	case (typeof (Sprite).name):
> 		child = this.addChild!(Sprite)(childName);
>
> 		break;
>
> 	case (typeof (Camera).name):
> 		child = this.addChild!(Camera)(childName);
>
> 		break;
>
>  	default:
>  		child = this.addChild!(Node)(childName);
>
> 		break;
> }
> --------------------------------------------------------------------------------

Ok, first of all, I'm not sure about the question, because of the 
following:

Does the default case handle an unspecified class or does it 
handle a class which is specified, but is not mentioned in any of 
previous cases?
Or does the default case handle both of these circumstances?
Without a master list this play an important role, I think.

Another information shortage is: are the tags exclusive or not? 
So, is it possible that a class has more then one tag (still 
being unique (tuple))?

Besides this, I tried something with types used as user defined 
attributes.
https://dlang.org/spec/attribute.html#uda

Automatic compile time tagging is not my speciality, however, I 
think is also achievable with mixins somehow?
But I don't know how to workaround the bug
https://issues.dlang.org/show_bug.cgi?id=18718
at this moment...

https://run.dlang.io/is/DmBhO5


More information about the Digitalmars-d-learn mailing list