Do you have any performance numbers for this design? In theory it should require fewer allocations but that may not matter if Hotspot can elide the allocations of short-lived wrapper objects entirely.
The proposed translation of : _*
is problematic. Currently this is the most efficient way of calling a varargs method. Simply pass an existing Seq
and it becomes a straight-forward method call with no extra allocations. With this proposal it would become the least efficient way: It always requires recreating the sequence, plus the external foldLeft
call makes it impossible for the curried varargs method to optimize based on the existing size or array-based internals of the sequence.
It would be nice if the proposal also addressed pattern matching. Can/should this be done by currying or does the new scheme keep the existing varargs pattern matching, thus making it less uniform.