4 ms·
What would you do about a slice function? Without the parameter names you won't even see if the second parameter is length of the slice or its right end.
by lostmsu 5y ago
What would you do about a slice function? Without the parameter names you won't even see if the second parameter is length of the slice or its right end.
- DaiPlusPlus 5y agoIn C# (prior to C# 8.0) without parameter names you would get an ambiguous overload error (and overload resolution is strictly by types, not by names - except for extension-methods). C# 8.0 side-stepped this problem by adding an explicit range operator. However I feel the best approach is to have first-class language support for parameter-arguments-to-type homomorphisms (e.g. `TArgs<YourMethod> args = new( arg1, arg2, arg3 ); YourMethod( args );`).
- skohan 5y agoYeah I agree there are examples where types are not enough to disambiguate arguments.