Skip to content

[Documentation] overloading using named arguments works but is not documented #11932

@PavelVozenilek

Description

@PavelVozenilek

I wanted to propose a very handy feature, overloading (also) based on named parameters. Basically this would compile:

proc foo(x : int) = echo "In foo1\n" proc foo(y : int) = echo "In foo2\n" foo(x = 2) # selects the first foo 

To my surprise, this minimal example already works. Could it be the feature is already there? However, nothing is currently publicly documented.

Perhaps there's fear that the language would feel too complex. But in this case, resolution based on argument names is very intuitive, both for learning the language and during reading the code. Keeping it out doesn't really help one to understand the other rules better.

So I suggest to make the feature visible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions