www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compile Time Scope Object?

reply Davidl <Davidl 126.com> writes:
Consider the following coding style

class AveryveryLongClassName
{

    void BuggyFunc()
    {
       debug writefln(`AveryveryLongClassName.BuggyFunc`);  // please no=
te  =

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=EF=BC=8Cit would be somemodule.AveryveryLongClassName.BuggyFun=
c
    void* Labels(arg)  //? perhaps it looks like AST macro for its argum=
ent
    			// 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 =3D {writefln("asdkfj");}
			// perhaps scope.exit should only work with ~=3D operator
			// then scope.exit ~=3D {writefln("asdkf"); would append to scope.exi=
t  =

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 ~=3D {writefln("adsfj");} is better than  =

scope(exit) and more D like

and scope.name would be useful for log
Apr 19 2007
parent Davidl <Davidl 126.com> writes:
and the idea is used to replace the __LINE__ __FUNCTION__
i think scope.line would be much nicer than __LINE__
and I don't see any good to bring a language with those
tokens. I'm quite sure they are just designed without
consideration of possible compile time object solution

 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 patc=
h
 	}
    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=EF=BC=8Cit would be somemodule.AveryveryLongClassName.BuggyF=
unc
     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 =3D {writefln("asdkfj");}
 			// perhaps scope.exit should only work with ~=3D operator
 			// then scope.exit ~=3D {writefln("asdkf"); would append to scope.e=
xit =
 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 ~=3D {writefln("adsfj");} is better than=
=
 scope(exit) and more D like

 and scope.name would be useful for log
Apr 19 2007