Adding a Methods type to Selectable, similar to Fields

Trying to provide a Selectable but for structs made out of vars, I find that Fields works really nice for applyDynamic, but I get nothing for selectDynamic. Given the existence of named tuples, it wouldn’t be hard to synthesize something like

// given
case class Point(x: Int, y: Int)
// produce
Selectable {
  type Fields = (x: Int, y: Int)
  type Methods = (x_= : (Int => Unit), y_= : (Int => Unit))
}

using the metaprogramming tools.

Alternatively, lacking this, I’m forced to, using just Fields, return some W[ActualType] for every field, and then provide an awkward := or similar operator to properly handle the operation.

Is the point here that Fields only ever delegates to selectDynamic? So you don’t want to return closures but still need to support dynamic method calls

I need to support vars basically, because structs behave like that, and I have no decent mechanism to do the “setters” because they are foo_=(v) methods.

1 Like

Ok gotcha specifically mutable fields, good point