apple / pkl

A configuration as code language with rich validation and tooling.
https://pkl-lang.org
Apache License 2.0
9.84k stars 259 forks source link

Optimization: `const` members should be cached for all children in prototype chain #508

Open bioball opened 1 month ago

bioball commented 1 month ago

The result of a const member cannot be late-bound, so its values should be cached for all children in the prototype chain.

As an observable effect, this should only result in one trace. Today, this has two.

class MyClass {
  const prop = trace("hello")
  res: Int
}

a = new MyClass { res = 1 }
b = (a) { res = 2 }