-
Notifications
You must be signed in to change notification settings - Fork 37
Description
It would be nice to either have a dynamic size of arguments like when using splat operators. We can either have it auto-converted into an Array or create a new type for iterating called Splat or Args.
Currently trying to use Array for an unknown size of parameters doesn't work.
I imagine specifying in the methods! macro that the Splat type will produce an iterator to sequentially produce Value objects from argc and argv.
Okay I believe I found the relevant info. What we want is rb_scan_args — Ruby C Extensions Part 6: Defining Functions. Additional info on it at The Definitive Guide to Ruby's C API. Helix has it already rb_scan_args
This debug code for scan_args shows the many ways to use it: scan_args/scan_args.c and includes how to make and Array from it return rb_ary_new_from_values(numberof(args), args) and -ext-/test_scan_args.rb shows the Ruby test side for those C methods.