would it break a bunch of stuff to allow destructi...
# language-evolution
h
would it break a bunch of stuff to allow destructing like this:
Copy code
fun foo((x, y): Pair<Int, Int>) = // whatever
j
Since you can simply destructure the argument with
val (x,y) = arg
in the first line of the body, I don't believe it would be worth complicating the language's syntax
1
👌 3
If you really want an expression as function body you can also do:
Copy code
fun foo(arg: Pair<Int, Int>) = arg.let { (x,y) -> 
  // Body
}
👍 2
e
wouldn't be able to call foo with named parameters under your proposed syntax
there may be some value in extending the language to allow for creating a binding distinct from the parameter name within the parameter list - e.g. maybe you want a different name locally, or want a var, or are destructing like this - but I haven't seen any proposals for that
j
i have an immutable Pai2 interface which intercepts
Pai2<Int,Int>
instantiated
1 t2 2
caught by dispatch as typealias as
Tw1n<Int>
which is then again shoved in 64 bit
Long
inline class backingstore, fwiw. Pairs (
Pai2
) of Ints and functions map well to immutable vectors and vectors of pairs, and vectors with special pair value treatments, and so on using typealiases with a single codebase. mutable `Pair`'s feel relatively crippled by comparison
the tuple support was more tuple-ee before "the change"