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"w, OBJ_MIN_CAP);
vm.defRTConst("PROTO_SLOT_IDX"w, PROTO_SLOT_IDX);
vm.defRTConst("FPTR_SLOT_IDX"w, FPTR_SLOT_IDX);
vm.defRTConst("ATTR_CONFIGURABLE"w  , ATTR_CONFIGURABLE);
vm.defRTConst("ATTR_WRITABLE"w      , ATTR_WRITABLE);
vm.defRTConst("ATTR_ENUMERABLE"w    , ATTR_ENUMERABLE);
vm.defRTConst("ATTR_DELETED"w       , ATTR_DELETED);
vm.defRTConst("ATTR_GETSET"w        , ATTR_GETSET);
vm.defRTConst("ATTR_DEFAULT"w       , ATTR_DEFAULT);

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) can be captured by the template, making it so that I don't also need to pass the name as a string. I expect the answer to be no, but maybe someone with more knowledge of D template magic knows better.

Reply via email to