[swift-evolution] mutating/non-mutating suggestion from a Rubyist

Vladimir.S svabox at gmail.com
Tue Apr 26 09:32:29 CDT 2016


I like this idea very much. I believe '&' should belong to instance 
variable, as it will be mutated, just like for inout parameter, so

c&.frobnicate(i)
let k = c&.frobnicate(&i)

very clear and explicit. Don't like the 'mutation' or even 'mut' as we'll 
have heavy code, as it is a word just like functions/methods/variable names 
and IMO harder to parse visually. '&' is a 'marker', that clearly parsed.

On 26.04.2016 16:48, Thorsten Seitz via swift-evolution wrote:
>
> As an alternative to the mutate keyword I rather like using '&' because it
> already means 'inout'. Using '&.' as mutating method call would therefore
> be quite understandable.
>
> c&.frobnicate(i)
> let k = c&.frobnicate(&i)
>
> Or marking the method like suggested elsewhere:
>
> c.frobnicate&(i)
> let k = c.frobnicate&(&i)
>
> -Thorsten


More information about the swift-evolution mailing list