3 ms·
There was an old java image manipulation API that I remember that had an API that looked like apply(Object o1) apply(Object o1, Object o2) apply(
by Marazan 3y ago
There was an old java image manipulation API that I remember that had an API that looked like
apply(Object o1)
apply(Object o1, Object o2)
apply(Object o1, Object o2, Object o3)
Etc
All the way out to 7 or 8 parameters. Magnificent work.
- ptx 3y agoJava didn't support varargs until version 5, so it might have been a workaround for that particular deficiency.
- ghosty141 3y agoReminds me of this "gem" in C#: https://learn.microsoft.com/en-us/dotnet/api/system.func-2?view=net-7.0 https://learn.microsoft.com/en-us/dotnet/api/system.func-2?v... You better not have more than 16 parameters with Func (which is kind of a good thing? Functions who take 16 parameters are pure evil).
- PaulHoule 3y agoIt is also a little faster to have a fixed number of parameters than to use varargs so it is not unusual for many libraries to have X(a) X(a, b) X(a, b, c) ... X(a, b, c, ..., ...rest) functions.
- Marazan 3y agoGood guess but it wasn't varargs, those were default value overrides IIRC. Thing that was objectionable it was that each an every argument was Object type. Absolutely no affordable whatsoever
- rjh29 3y agoStill exists in Rust, e.g. https://doc.rust-lang.org/std/primitive.tuple.html#impl-From%3C(T,+T)%3E-for-%5BT;+2%5D https://doc.rust-lang.org/std/primitive.tuple.html#impl-From... or https://docs.rs/itertools/latest/itertools/structs/struct.Tuples.html#impl-MultiUnzip%3C()%3E-for-Tuples%3CI,+T%3E https://docs.rs/itertools/latest/itertools/structs/struct.Tu...