Skip to main content

reorder_builtin_args

Function reorder_builtin_args 

Source
fn reorder_builtin_args(
    positional: &[RValue],
    named: &[(String, RValue)],
    formals: &[&str],
) -> (SmallVec<[RValue; 4]>, SmallVec<[(String, RValue); 2]>)
Expand description

Reorder positional and named args to match the builtin’s formal parameter order.

When formals is non-empty, named args that match a formal are placed at the corresponding slot, and remaining positional args fill the unmatched slots left-to-right. This is the same matching R does for closures, applied at the builtin dispatch boundary so every builtin benefits automatically.

When formals is empty (variadic / dots builtins), args pass through unchanged.