-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named only parameters. #719
Comments
This is a great idea IMO ; as discussed on Discord, there could also be a case for positional-only arguments, for functions where the argument names carry absolutely no information (eg |
As also discussed on github: My idea is that every keyword-only argument must include the Fine: Func(arg1 = 5, .arg2 = 6, .arg3 = 7)
{
} Error: Func(arg1 = 5, .arg2 = 6, arg3 = 7)
{
} This restriction could in theory be lifter later if a reasonable solution to this is found (but I'm not holding my breath). |
@Y-Less If the user wants to make a pass-by-reference argument named-only, should the compiler expect the Func(.&arg) {} , or the Func(&.arg) {} |
Issue description:
So I've recently been using named parameters a lot more:
If you don't know, this is a way to only specify specific optional parameters instead of all of the preceding ones:
Even if you use
_
as "default" it is still a bit unwieldy:Anyway, this isn't to talk about call sites, but declaration sites:
It would be nice to extend the
.
syntax to here as well to make parameters that can only be called via named parameter syntax:This gives library writers way more flexibility in their optional arguments as they are no longer bound to a specific order, as people can no longer call the function with only positional arguments.
The text was updated successfully, but these errors were encountered: