Skip to content

Improve the usability of outer #1195

@HT154

Description

@HT154

cf. Peter's old notes

Currently, outer.foo literally accesses foo on outer. Instead, it should work more like super.foo, i.e., access the lexically closest foo, not necessarily on the directly enclosing object. Perhaps outer.foo should 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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions