sclass LASScope { // variables declared in this scope, with type/value description gettable new Map declaredVars; // optional parent scope // (we can see the parent's variables in this scope too, unless they // are redeclared) settable LASScope parentScope; // true = we may outlive the parent scope // (e.g. when we're a lambda) settable bool parentIsDetached; // sorted names when scope is finalized S[] names; *() {} *(LASScope *parentScope) {} int resolveVar(S name) { resolve(); ret indexOfInSortedArray(names, name); } void resolve { if (names != null) ret; names = empty(declaredVars) ? null : toStringArray(sortedKeys(declaredVars)); } }