[swift-evolution] [Pitch] Replace 'inout' with '&'
matthew at anandabits.com
Fri Dec 18 20:30:11 CST 2015
Sent from my iPad
> On Dec 18, 2015, at 8:21 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>> On Dec 18, 2015, at 6:08 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>>> On Fri, Dec 18, 2015 at 5:23 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>>> For Swift 3, we're planning to phase out 'var' parameters in functions, and we're also making it so that language keywords are valid argument labels. With both of these changes pending, I have a hard time not reading:
>>> func foo(inout x: Int)
>> I don't think this would be a problem in practice since it is hard for me to imagine an API that would use 'inout' as a label -- at least they would spell it 'inOut' according to our API guidelines (but I really think they should call it something else).
> My main concern is readability of the declaration. 'func foo(inout x: Int)' and 'func foo(label x: Int)' look very similar at a glance, but have totally different meanings. Going back to '@inout' like Slava suggested would be another possible improvement.
I wasn't thinking about the future with my initial vote. I definitely want to see a Rust-like ownership system someday and am excited to know that Chris is really interested in doing that eventually. It's probably best to do something that will fit into that world well. So maybe @inout is a better option.
>> There's also a possibility that we add 'out' parameters in the future, and if 'inout' would be spelled '&', then we would need to find another sigil for 'out'.
> We have multiple returns. Why would we ever add out parameters?
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution