refaktor / rye

homoiconic dynamic programming language with some new ideas
https://ryelang.org
Apache License 2.0
406 stars 21 forks source link

Add CallFunctionArgsN #272

Closed xypwn closed 1 month ago

xypwn commented 1 month ago

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.

xypwn commented 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