[swift-evolution] [Proposal] Adjusting `inout` Declarations for Type Decoration

Charles Kissinger crk at akkyra.com
Fri Jan 29 17:42:33 CST 2016


Sorry, I wasn’t clear at all there. I was thinking of the most common case where there is either only one parameter or the inout parameter is the first one. Then there will typically be no argument label involved at the call site. In that case ‘inout’ will be the first word inside the parens at the call site (assuming it replaces ‘&’). If it also is kept in its current position in function declarations, it will be in that same leading position in declarations and (I’m assuming) people will have an easy time remembering where to put it.

When there is a label involved, it is a different story. I was implicitly, and probably wrongly, assuming that would be a much less common case in practice. A poorly worded, and probably poorly reasoned, argument on my part, though I still don’t see any great advantage to replacing ‘&'.

—CK

> On Jan 29, 2016, at 2:13 PM, Erica Sadun <erica at ericasadun.com> wrote:
> 
> 
>> On Jan 29, 2016, at 3:04 PM, Charles Kissinger <crk at akkyra.com <mailto:crk at akkyra.com>> wrote:
>> The related idea of replacing ‘&’ with ‘inout’ at the call site seems completely contradictory to this proposal. Developers would then have to remember that the ‘inout’ goes before the argument at the call site but after it in the function definition. That seems like a constant source of mis-typings and something that would be viewed as an inconsistency in the language. Or do people want to put it after the argument name at the call site too? It seems a little like change just for the sake of change, IMO.
> 
> If you have a function
> 
> f(x: Int) {}
> 
> you call it with f(8), and potentially f(x: 8). Even when labeled, the 8 value is to the right of the colon.
> 
> Now consider
> 
> f(x: inout Int) {}
> 
> you call it with f(&y) or f(inout y), and with a label, you'd call it f(x: &y) or f(x: inout y).
> 
> It seems  consistent to me.
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160129/9037ad02/attachment.html>


More information about the swift-evolution mailing list