2 ms·
I don‘t really see a significant difference between overloaded methods and a single method with a sum type (where, in the general case, the sum is over the para
by layer8 6y ago
I don‘t really see a significant difference between overloaded methods and a single method with a sum type (where, in the general case, the sum is over the parameter-list tuple types of the overloaded methods). One can interpret the former as syntactic sugar for the latter.
- recursivedoubts 6y agoStatic vs dynamic dispatch, to start with. You need default values (and ideally named parameters) to really make them equivalent, but yes, both address a similar set of developer needs. The java implementation, where it bleeds into bytecode and method scoring in insane ways, is particularly unfortunate.
- diroussel 6y agoBut it’s not actually syntactic sugar in java. There is a whole concept of type-signature which is part of method look up. Without overloading lookup would just be via name.