I was just thinking of this, because of a design decision i find to be absolutely wrongheaded;
I tried to use varargs, because i really really want to make my functions take one or many without having to deal with converting to a list on the case of ‘one’, and besides i often have to convert.
So i tried varargs. Then i had the problem of ‘conversion’ or ‘mapping’ (functional lingo). And then i had the problem that as varargs uses arrays it needs to have the non-generic class type (arrays being covariant and all).
What i’d really like is that varargs created a iterable that could then be easily wrapped in another iterable that could do the mapping (with lambdas or whatever). However due to the fact that arrays are covariant and not lazy i need to pass a collection (for the size()), a class (to instantiate the array) and the factory ‘lambda’) and waste time and space copying.
I’ve reached the conclusion that varargs do more harm than good in cases where you need to transform one-or-many into the function arguments expected, and that it’s better to do ‘asList’ on the function arguments that are not on collection form and pass a iterable.
Varargs was implemented targeting the wrong type and is almost completely useless!
Have you got any other pet issues?