Skip to content

Splat of parameters from Ruby (variadic function) #90

@danielpclark

Description

@danielpclark

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions