[swift-evolution] thoughts on 'inout'
Brent Royal-Gordon
brent at architechies.com
Thu Feb 11 17:29:38 CST 2016
> My gut reaction to typing 'inout' in front of every parameter I want to call by reference is that it makes code look rather waffly.
>
> So I'm reflecting an idea on this:
>
>
> Use = to assign values.
>
> Use : to associate variables.
>
>
>
> A function declaration would look like this:
>
> func addInt(add intToAdd = Int, to counterInt : Int ) {
> counterInt += intToAdd
> }
This doesn't work with unlabeled parameters. I think it also makes inout parameters too invisible; they have unusual semantics and ought to be marked. I don't think it's a good idea to overload `=` for parameter passing; it requires different spacing to look right, and the change would alter literally every method call in existing code. `=` is also semantically heavier than `:`, and yet it's being used in the lighter role here. And I think it makes inout parameters too "easy"—they're a pretty rare case and it's okay to require more than zero extra characters to declare them.
In short, -1.
--
Brent Royal-Gordon
Architechies
More information about the swift-evolution
mailing list