try the following
Code:
local a={}.setdelegate(
{
function _get(idx)
{
return function()
{
::print(idx);
}
}
});
local z=a.b();
the problem is that with
local z=a.b();
the 'this' passed to the innermost function is 'a' so the _get is invoked again to try to fetch 'print' (if you woudn't have a getter then it would fallback to root automatically).
local z=(a.b)();
that is equivalent to
local temp = a.b;
temp();
in this case the 'this' is the root table, that does have a 'print' slot.
with the :: you tell the compiler, "just fetch this from the root".
I hope this makes sense
ciao
Alberto