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

Erica Sadun erica at ericasadun.com
Fri Jan 29 17:50:03 CST 2016


The great advantages are:

1. It removes a potentially confusing overlap with C-style expectations. People see & and think "POINTERS!", which is not how things work in Swift with copy-back.
(2. It eventually frees up &, so we can have more Rust)

-- E

> On Jan 29, 2016, at 4:42 PM, Charles Kissinger <crk at akkyra.com> wrote:
> 
> 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 <mailto: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/aaf266fa/attachment.html>


More information about the swift-evolution mailing list