http://www.newton-inc.com/dev/techinfo/qa/qa.htm
myEncloser := {
importantSlot: 42,
GetImportantSlot := func()
return importantSlot,
nestedSlot := {
myInternalValue: 99,
getTheValue := func()
begin
local foo;
foo := :GetImportantSlot(); // WON'T WORK; can't find function
foo := myEncloser:GetImportantSlot(); // MAY WORK
importantSlot := 12; // WON'T WORK; will create new slot in nestedSlot
myEncloser.importantSlot := 12; // MAY WORK
end
}
};
myEncloser.nestedSlot:GetTheValue();
The proper way to accomplish this is to give the nested frame a _parent
or _proto
slot that references the enclosing frame. Nesting the frame is not strictly necessary in this case, only the _proto
or _parent
references are used.