apple / apple/pkl

Improve the usability of `outer`

Open
#1,195 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
11.5k
Forks
402
Avg merge
1d 15h
Merged PRs (30d)
20

Description

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:
```pkl
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"`.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing how `outer.foo` and `super.foo` are currently resolved, using the nested `A` and `B` example as the behavioral baseline. Determine the intended lexical lookup rules, including parameters and local properties, then add coverage for the proposed behavior and its breaking-change cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.