Global lookup in MiniD 1 will check to see if the global exists in 'this' before continuing on to the function's environment. The problem with this is that it introduces some nasty ways to hijack code, as well as making some stuff unintuitive. For example:
class A
{
function toString()
{
return toString(6);
}
}
This will cause infinite recursion, because toString is found in 'this' before it goes to global scope. You instead have to write _G.toString(6). This isn't so much a problem in D because you get an error at compile time, but in MiniD you get an infinite loop..
What's worse is that code that worked before can be made to stop working or work differently by i.e. dynamically adding a method into an object. Suddenly another method, which called a global function by the same name, now calls the new method instead.
global function foo()
{
writeln("global foo!");
}
global class A
{
function test()
{
foo();
}
}
global a = A();
a.test(); // prints "global foo!"
A.foo = function() { writeln("local foo!"); };
a.test(); // prints "local foo!"
This is pretty awful, and even I've been bitten by such things in my (relatively limited) experience with the language.
To that end, MiniD 2 will do away with this behavior. However having to type out this. at the beginning of every field/method access is tedious; just look at any Python code. ;) I've introduced a shortcut expression: instead of this. you can write :, so this.x can be written :x, and this.("x") can be written :("x"). Yes, this is a breaking change, but objects are already changing drastically, so..
So global lookup now basically skips the old first step of checking in 'this' and just starts with the function's environment.