From 886bcc6b7ddaabb020de392acf3528b182bd0973 Mon Sep 17 00:00:00 2001 From: Mica White Date: Thu, 24 Sep 2026 17:58:27 -0400 Subject: Stuff --- src/blog/named-optional-args.kuht | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/blog') diff --git a/src/blog/named-optional-args.kuht b/src/blog/named-optional-args.kuht index 7d36972..874ea57 100644 --- a/src/blog/named-optional-args.kuht +++ b/src/blog/named-optional-args.kuht @@ -654,7 +654,7 @@ split("hello world", .at = ' ', .limit = 2, .case_sensitive = true); will satisfy as many people as possible. I'll monitor the comments anywhere this gets posted to see if there are any major criticisms. I can't guarantee that I'll actually make an RFC, but permission is granted to create an RFC if - I don't. I think it's been a while since named argument were last seriously + I don't. I think it's been a while since named arguments were last seriously proposed, so I think now is a good time for a new proposal.

@@ -991,8 +991,7 @@ trait Trait { impl Trait for () { // This is okay, because the parameter names match - // unused parameter warnings can be ignored using @ - fn f(pub a: i32, pub b @ _: i32) {} + fn f(pub a: i32, pub b: i32) {} } impl Trait for i32 { @@ -1079,7 +1078,7 @@ CallParams = CallParam ( "," CallParam )* ","? FunctionParamPattern = "pub" pat:IdentifierPattern ":" ( ty:Type | "..." ) ( "=" expr:Expr ) -

similar rules to the rules for default field values apply. Namely,

+

Similar rules to the rules for default field values apply. Namely,

@@ -1253,8 +1248,8 @@ coordinates(y, x);

Although many languages, such as Kotlin and C#, allow any argument to be - named, this is not practical for Rust. Changing an argument is currently not - a breaking change, but would become one as soon as named arguments are + named, this is not practical for Rust. Changing an argument name is currently + not a breaking change, but would become one as soon as named arguments are introduced. The solution is to allow authors to decide if their argument names are an implementation detail or not.

@@ -1518,6 +1513,16 @@ enableFlags(bold: true)

Future possibilities

+

Default parameter values for non-public parameters

+ +

+ In this proposal, only public parameters can have default values. Optional + named parameters are much more flexible than optional positional parameters, + but many languages do still support optional positional arguments. It's not + hard to imagine extending this proposal to positional arguments, although the + use-case would be more limited. +

+

Default parameter values for trait methods

-- cgit v1.3.1