Currently scala only allow a setter with single argument e.g.
class A: val _a: mutable.Seq = Seq.empty inline def f: Seq[String] = _a inline def f_=(s: Seq[String]) = ... // Allowed inline def f_=(i: Int, s: String) = _a(i) = s // Not allowed
Should scala add support for the third function signature? It will allow us to use:
val a: A = ??? a.f = Seq(...) a.f(i) = "string" // doesn't work currently
We can approximate this by making
inline def f = ... return a class which defines a
inline def update(i: Int, s: String) but since classes can’t be inlined currently, the resulting code is not fully inlined.
Also, we lose
inline def f returning a meaningful value, and have to define a
inline def apply() on the intermediate class, which has to called as
a.f() instead of