<div dir="ltr">C# uses its `ref` keyword in both function declarations and call sites (see <a href="https://msdn.microsoft.com/en-us/library/14akc2c7.aspx">https://msdn.microsoft.com/en-us/library/14akc2c7.aspx</a>), and I don&#39;t think people consider that syntax to be penalized or an edge case.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 29, 2016 at 8:32 PM, Kevin Ballard via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>




<div><div>-1<br></div>
<div> </div>
<div>I feel like the people who are voting +1 probably don&#39;t actually <i>use</i> inout parameters very often, because it seems very obvious that requiring the label &quot;inout&quot; at the function call site is extremely unwieldy. inout parameters aren&#39;t some weird edge case that we want to penalize, they&#39;re a perfectly legitimate feature of the language, and they should be relatively easy to call.<br></div>
<div> </div>
<div>-Kevin Ballard<br></div><div><div class="h5">
<div> </div>
<div>On Fri, Jan 29, 2016, at 02:44 PM, Trent Nadeau via swift-evolution wrote:<br></div>
</div></div><blockquote type="cite"><div><div class="h5"><div dir="ltr"><div><a href="https://github.com/tanadeau/swift-evolution/blob/master/proposals/00xx-use-inout-at-func-call-site.md" target="_blank">https://github.com/tanadeau/swift-evolution/blob/master/proposals/00xx-use-inout-at-func-call-site.md</a><br></div>
<div> </div>
<div><pre style="color:rgb(0,0,0)"># Use `inout` at Function Call Sites

* Proposal: TBD
* Author(s): [Trent Nadeau](<a href="http://github.com/tanadeau" target="_blank">http://github.com/tanadeau</a>)
* Status: TBD
* Review manager: TBD

## Introduction

Currently when a function has `inout` parameters, the arguments are passed with the `&amp;` prefix operator. For example:

```swift
func add1(inout num: Int) {
    num += 1
}

var n = 5
add1(&amp;n) // n is now 6
```

This operator does not fit with the rest of the language nor how the parameter is written at the function declaration. It should be replaced so that `inout` is used in both locations so that the call site above would instead be written as:

```swift
add1(inout n) // symmetric and now obvious that n can change
```

*Discussion thread TBD*

## Motivation

The `&amp;` prefix operator is a holdover from C where it is usually read as &quot;address of&quot; and creates a pointer. While very useful in C due to its pervasive use of pointers, its meaning is not the same and introduces an unnecessary syntactic stumbling block from users coming from C. Removing this operator and using `inout` removes this stumbling block due to the semantic change.

This operator is also disconnected from how the function declaration is written and does not imply that the argument may (and likely will) change. Using `inout` stands out, making it clear on first read that the variable may change.

It is also possible that Swift may add Rust-like borrowing in the future. In that case, the `&amp;` symbol would be better used for a borrowed reference. Note that Rust uses the same symbol for declaring a borrowed reference and creating one, creating a nice symmetry in that respect of the language. I think Swift would want to have such symmetry as well.

## Detailed design

```
in-out-expression → inout identifier
```

## Alternatives Considered

Keeping the syntax as it currently is.<br></pre><div> </div>
<div>-- <br></div>
<div>Trent Nadeau<br></div>
</div>
</div>
</div></div><span class=""><div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</span></blockquote><div> </div>
</div>

<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Trent Nadeau</div>
</div>