The example given in the previous mail where a bunch of constants are declared in a function scope has brought an idea to ease declarations of such constants when there is an important number of them. It would bring module-like capabilities, decoupling the internal layout of modules from the usage made by clients of that module.
If the function context could be accessed as a variable in a similar way that the global object can be accessed in the global scope through "this", we could simply write a function that installs all those declarations on the context object. Here is an example:
function foo () { var context = foo.getContext(); x86.import(context); // or it could be context.import(x86)
// Some cleaner code here var mem_access = _(ESP); }
x86.import = function (context, /* optional */ import_list) { if(import_list) { for (var i in import_list) { context[i] = x86[i]; } } else { context["_"] = x86._; context["ESP"] = x86.register.ESP; //... }
}
Given that we will have access to the internals of the compiler, I think it would be a reasonable extension, after the bootstrap is done. It would however prevent us from bootstrapping on a stock javascript engine. We might find a workaround using eval but that would violate our "no-eval" policy.
Erick