[swift-evolution] [Proposal] Use inout at function call sites

T.J. Usiyan griotspeak at gmail.com
Fri Jan 29 21:51:11 CST 2016

+1 for the added symmetry and searchability

On Sat, Jan 30, 2016 at 4:45 AM, Brent Royal-Gordon via swift-evolution <
swift-evolution at swift.org> wrote:

> > add1(&n) // n is now 6
> > add1(inout n) // symmetric and now obvious that n can change
> I'm not a really big fan of this change; despite being longer, `inout n`
> is less visible to me than `&n`. But this is a relatively weak preference—I
> could certainly live with it.
> More important than changing the symbol might be restricting its use. I
> don't see any particularly good reason to permit you to say `let x = &y`.
> Far better to use `withUnsafePointer()` to control the scope of the
> pointer, or at least say something like `let x = unsafeInoutPointer(&y)` to
> acknowledge that you're circumventing memory safety and possibly taking a
> pointer to a temporary. Basically, I think `&` or `inout` or however we
> spell it should only be allowed as a parameter, not just anywhere in any
> expression.
> --
> Brent Royal-Gordon
> Architechies
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160130/48defaea/attachment.html>

More information about the swift-evolution mailing list