compile-time function in a class?

Davidl Davidl at 126.com
Tue Mar 20 07:03:28 PDT 2007


static keyword is already used by class.
and i hope

static static compiletimefunc()
{
}
can be recognized as a compiletime func

all i want is the name space protection from my class.

like if i want to do some code injection for my certain class
attributes. like
class abc
{
    mixin(compiletimefunc(`membera,memberb`));
//pusedo code begines:
    static static compiletimefunc(char[]members)
    {
        char []result;
        //parse members to membernames
        result~=`private:int _m_`~membernames~`;`;
        result~=`public:int member(){return _m_`~membernames~`}`;  //getter
	// loop
	return result;
    }
}

actually the compiletimefunc only used by the class abc, but now i can do
is make it outside the class and polute the name space.



More information about the Digitalmars-d mailing list