Re:Storehaus from Twitter
by ryangreenberg on Wednesday March 20, 2013 @11:08PM
(#5412583)
The 22 overloaded versions of Future#join is a consequence of wanting to supporting all the possible method calls. It goes up to 22 because that is the limit to possible number of arguments in Scala. See, for example, the corresponding Function22 (https://github.com/scala/scala/blob/master/src/library/scala...) and Tuple22 case class (https://github.com/scala/scala/blob/master/src/library/scala...) from the Scala source.
You can't just use a catch-all argument like xs: Future* because you have to parameterize the types of the arguments.
Scala has Tuples, so you can declare:
val t = ("hello", 42)
You guys should love this! It makes something Java-compatible (a Tuple2<String, Integer>), while being a bazillion times less verbose.The price for doing this in the JVM with reasonable Java-compatibility is that Tuple2<A,B> is a different class than Tuple3<A,B,C> than Tuple4<A,B,C,D>. Tuple goes to 22.
Collections-like frameworks dealing with Tuples often have to generate versions of methods that operate on one of each version of tuple, which is why you see 22 methods here, one to generate each version.
As much as I think scala is a little kitchen sink already, and macros are yet another feature I don't think people need in scala, they'd be useful to generate this code pattern.
I go check what it is, and find this WTF (line 158 and on):
https://github.com/twitter/util/blob/master/util-core/src/ma...