Closed xypwn closed 1 month ago
Varargs/slices/maps only heap-allocate if they really need to. A lot of the time, the compiler can figure out that they can just be stack-allocated.
Here is an example that shows that fixed args, varargs and slices don't allocate any memory in simple cases (CallFunctionArgsN should also be such a simple case): https://go.dev/play/p/Nb9uZK40aqc
AFAIK, it wasn't possible to call a func from go code, which has exactly 3, or more than 4 args. This change adds a function "CallFunctionArgsN", which allows calling a function with any number of args.