Compile Time Scope Object?
Davidl
Davidl at 126.com
Thu Apr 19 09:42:08 PDT 2007
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 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