3 ms·
Another day, another example for why argument labels and variadics are really nice to have ;)
by saagarjha 5y ago
Another day, another example for why argument labels and variadics are really nice to have ;)
- cm2187 5y agoActually it’s not. This is to call any other macro (function), the first argument is the name of the macro as a string, and the other arguments are the parameters that will be provided to that macro, which can be of any type and have any name. So it kinds of need to be that way.
- saagarjha 5y agoRight, so this would be something like Application.Run(macro: Object, arguments: Object...) which would clean it up nicely.
- cm2187 5y agoThat’s what the definition a bit further down the page says. The header of the page seems to be the function signature so it doesn’t contain any name.
- saagarjha 5y agoIn languages with argument labels, they are part of the signature and show up in the call site.
- trynumber9 5y agoC# does have optional named parameters (see link below). But it is little help here as this is an old COM library for Excel. The documentation says named parameters are not supported for this method, which is a COM interop limitation but not a limitation of the C# language. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...
- alkonaut 5y agoEVen in .net that HAS variadics, there are no stack allocated variadics (yet) so you'll often see 8 overloads with foo(T arg1) foo (T arg1, T arg2) foo(T arg1, T arg2, T arg3) and so on up to foo(params T[] args) because you want to avoid the overhead of actully allocating an array only to pass to one method, if you can. You'd think this kind of thing could be unfolded at compile time instead of requiring manual overloads.