summaryrefslogtreecommitdiff
path: root/src/blog/named-optional-args.kuht
diff options
context:
space:
mode:
Diffstat (limited to 'src/blog/named-optional-args.kuht')
-rw-r--r--src/blog/named-optional-args.kuht27
1 files changed, 16 insertions, 11 deletions
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.
</p>
@@ -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 )
</pre>
-<p>similar rules to the rules for default field values apply. Namely,</p>
+<p>Similar rules to the rules for default field values apply. Namely,</p>
<ul>
<li>
If the function is <code>const</code>, then the expression, <code>expr</code>
@@ -1114,11 +1113,7 @@ foo::&lt;T>();
placed on a <code>FunctionParam</code>, it also applies to the expression,
<code>expr</code>.
</li>
- <li>
- Unused parameter names will not emit a warning if they are bound to a
- different pattern using <code>@</code>. The bound pattern may still emit a
- warning
- </li>
+ <li>Unused parameter names will not emit a warning.</li>
</ul>
<p>
@@ -1253,8 +1248,8 @@ coordinates(y, x);
<p>
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.
</p>
@@ -1518,6 +1513,16 @@ enableFlags(bold: true)
<h3>Future possibilities</h3>
+<h4>Default parameter values for non-public parameters</h4>
+
+<p>
+ 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.
+</p>
+
<h4>Default parameter values for trait methods</h4>
<p>