Improve the usability of `outer`
cf. Peter's old notes
Currently,
outer.fooliterally accessesfooon outer. Instead, it should work more likesuper.foo, i.e., access the lexically closestfoo, not necessarily on the directly enclosing object. Perhapsouter.fooshould also work for method parameters and local properties, e.g.function myFunction(bar) = new { bar = outer.bar }
This is a potentially breaking change in cases like this:
class A {
foo: String = "baz"
b: B
}
class B {
foo: String
}
foo: String = "bar"
a: A = new {
b {
foo = outer.foo
}
}
In the current state, a.b.foo is "baz" since outer refers to a. As proposed, if outer.foo refers to the "lexically next outer" foo then a.b.foo is "bar".
This would definitely be a breaking change.
d = 5
a = (prop) {
b {
// currently, resolves to `6`.
// If changed to "lexically closest `d`", this lookup resolves to `5`.
c = outer.d
}
}
prop {
d = 6
}
I don't think this makes sense to change now. But, one paper cut here is that outer can only look up one level higher. Possibly, we should allow outer to be chained.