Re: Capture parameter identifier name in a template?

2014-08-14 Thread Rémy Mouëza via Digitalmars-d-learn
I have just checked it and yes, it works with a constant that is not an enum: `const int FOO` defined in the module namespace or `static int BAR` defined in the dummy Vm class. On 08/14/2014 02:08 PM, Maxime Chevalier-Boisvert wrote: > Thanks. Does it also work with a constant that's not an enu

Re: Capture parameter identifier name in a template?

2014-08-14 Thread Rémy Mouëza via Digitalmars-d-learn
Using __traits (identifier, ...) and a template alias seems to work for me: import std.stdio; /// Two kinds of enums: /// A named enum. enum VmParams { OBJ_MIN_CAP, PROTO_SLOT_IDX, FPTR_SLOT_IDX, } /// An anonymous one. enum { ATTR_CONFIGURABLE = 3, ATTR_WRITABLE, ATTR_

Re: Capture parameter identifier name in a template?

2014-08-12 Thread Dicebot via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 17:36:41 UTC, Maxime Chevalier-Boisvert wrote: In my JavaScript VM, I have a function whose purpose is to expose D/host constants to the JavaScript runtime code running inside the VM. This makes for somewhat redundant code, as follows: vm.defRTConst("OBJ_MIN_CAP"

Re: Capture parameter identifier name in a template?

2014-08-12 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 12, 2014 at 05:36:40PM +, Maxime Chevalier-Boisvert via Digitalmars-d-learn wrote: > In my JavaScript VM, I have a function whose purpose is to expose > D/host constants to the JavaScript runtime code running inside the VM. > This makes for somewhat redundant code, as follows: > >

Re: Capture parameter identifier name in a template?

2014-08-12 Thread ketmar via Digitalmars-d-learn
On Tue, 12 Aug 2014 17:36:40 + Maxime Chevalier-Boisvert via Digitalmars-d-learn wrote: > I'm just wondering if there's a way to template defRTConst so > that the name of an identifier I'm passing (e.g.: ATTR_DEFAULT) seems that this is the work for mixins. signature.asc Description: PGP s