Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Another day, another example for why argument labels and variadics are really nice to have ;)



EVen 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.


Actually 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.


Right, so this would be something like Application.Run(macro: Object, arguments: Object...) which would clean it up nicely.


That’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.


In languages with argument labels, they are part of the signature and show up in the call site.


C# 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-g...




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: