Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Apr 28, 2014 at 8:20 PM, Dicebot via Digitalmars-d-learn wrote: > You can do the same iterating directly over allMembers list, why would you > prefer array here? Hmm, indeed. One advantage would be to get a range, and thus the power and filtering, mapping and co.

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Dicebot via Digitalmars-d-learn
On Monday, 28 April 2014 at 17:40:54 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: On Mon, Apr 28, 2014 at 5:45 PM, Andrej Mitrovic via Digitalmars-d-learn wrote: If you need to store the tuple as an array to some variable, then you would use that syntax. It all depends on what you're tr

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Apr 28, 2014 at 5:45 PM, Andrej Mitrovic via Digitalmars-d-learn wrote: > If you need to store the tuple as an array to some variable, then you > would use that syntax. It all depends on what you're trying to do from > the call site. Ultimately it won't matter much once we finally get a >

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Andrej Mitrovic via Digitalmars-d-learn
On 4/28/14, ParticlePeter via Digitalmars-d-learn wrote: > I found the code with parenthesis in the dlang __traits docs and > also Philippe Sigauds "D Templates", and I haven't seen any other > example which works without them. So, when to use which syntax ( > for which purpose ) ? If you need to

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread ParticlePeter via Digitalmars-d-learn
On Monday, 28 April 2014 at 13:57:56 UTC, Andrej Mitrovic wrote: On Monday, 28 April 2014 at 13:52:52 UTC, ParticlePeter wrote: DMD tells me "Error: variable m cannot be read at compile time", but why ? Because 'static foreach' is not an explicit feature yet, so it depends on the context. Whe

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Andrej Mitrovic via Digitalmars-d-learn
On Monday, 28 April 2014 at 13:52:52 UTC, ParticlePeter wrote: DMD tells me "Error: variable m cannot be read at compile time", but why ? Because 'static foreach' is not an explicit feature yet, so it depends on the context. When you wrap the trait via: [__traits(allMembers, MyStruct)] You'

How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread ParticlePeter via Digitalmars-d-learn
DMD tells me "Error: variable m cannot be read at compile time", but why ? [code] struct MyStruct { float float_value = 0.0f ; ubyte ubyte_value = 2 ; } enum members = [ __traits( allMembers , MyStruct ) ] ; foreach( m ; members ) { mixin( "writeln( " ~ m ~ " , \" : \" , ( My