I have this line of code, where I use the most idiomatic way I know, for destructuring an object coming back from a function:
val (a, b) = foo match { case MyObjectType(a, b) => (a, b) }
The object's prototype being:
case class MyObjectType(Type1: SomeType1, Type2: SomeType2)
Of course I could otherwise:
val returnType = foo
val (a, b) = (returnType.a, returnType.b)
But the latter is rather a different form of stating the same problem - this is really not elegant. Could a Scala macro come to the rescue to provide a succinct idiom? perhaps allowing syntax like either:
val (a, b) = foo deconstruct { MyObjectType(a, b) => (a, b) } // merely more shorthand, like scala allows e.g. within a map block
val (a, b) = tuplize(foo) // assumes tuplize can iterate the vals of MyObjectType
tupleResult(a, b) = foo // radical macro api exploring the limits of macro safety...
tupledVars(foo) // macro extreme