Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulating variadic templates in Scala

Suppose you want to have something like variadic templates (the ability to define n type parameters for a generic class) in Scala.

For example you do not want to define Tuple2[+T1, +T2] and Tuple3[+T1, +T2, +T3] but Tuple[T*].

Are there other options than HLists that would support Tuple, Product and Function?

like image 286
Thomas Jung Avatar asked Apr 07 '10 15:04

Thomas Jung


1 Answers

At the moment there's no syntactical construct in Scala which allows what you're suggesting. That's also the reason why there are 22 Tuple classes (Tuple2, Tuple3, ..., Tuple22) and also different Function classes (Function0, ...).

like image 140
Michel Krämer Avatar answered Nov 03 '22 08:11

Michel Krämer