Skip to content

Introduce a :*@foo slurpy named argument syntax #452

Open
@lizmat

Description

@lizmat

Inspired by rakudo/rakudo#2797

This would allow:

% raku -e 'sub foo(:@bar) { dd @bar }; foo :bar<a>' 
Type check failed in binding to parameter '@bar'; expected Positional but got Str ("a")
  in sub foo at -e line 1

to just work like:

% raku -e 'sub foo(:@bar) { dd @bar }; foo :bar<a b>'
("a", "b")

The syntax is currently a compilation error:

% raku -e 'sub foo(:*@bar) { dd @bar }; foo :bar<a>' 
===SORRY!=== Error while compiling -e
Missing block
at -e:1
------> sub foo(:⏏*@bar) { dd @bar }; foo :bar<a>

Disadvantages: apart from the grammar work, this would also need quite a bit of work in the binder. And the user would need to know to specify :*@foo instead of :@foo.

Advantages: would be generally useful, and would allow the "adapt the Capture hack" in MAIN handling to be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    languageChanges to the Raku Programming Language

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions