Compile Time Scope Object?

Davidl Davidl at 126.com
Thu Apr 19 09:34:18 PDT 2007


Consider the following coding style

class AveryveryLongClassName
{

    void BuggyFunc()
    {
       debug writefln(`AveryveryLongClassName.BuggyFunc`);  // please note  
this is trouble some
    }
}

and consider the following forward reference of labels
void func()
{
	asm
	{
		mov EAX, label1;		//currently it's impossible like for some hot patch
	}
   label1:

}


what i think is bringing a new Compile Time Object for each scope
the scope compiletime object should give users the following :

scope
{
    char[] name;	//name for the scope, like in the previous mentioned  
BuggyFunc,it would be somemodule.AveryveryLongClassName.BuggyFunc
    void* Labels(arg)  //? perhaps it looks like AST macro for its argument
    			// coz i want to feed scope.Labels(label1)
			// maybe it's foreachable ?
    scope parent;    // give the parent scope ocmpile time structure
    scope[] child;   // give the child scopes
    void delegate() exit;
			// with this we can do the scope(exit) in a cleaner way
			// scope.exit = {writefln("asdkfj");}
			// perhaps scope.exit should only work with ~= operator
			// then scope.exit ~= {writefln("asdkf"); would append to scope.exit  
list }
    void delegate() failure;
    void delegate() success;
    int BeginLine,EndLine; 	// maybe provide the line numbers for the  
current scope?
}

I think the way of scope.exit ~= {writefln("adsfj");} is better than  
scope(exit) and more D like

and scope.name would be useful for log



More information about the Digitalmars-d mailing list