Oftentimes one wishes to assign to a variable a modified version of itself, but a special assignment operator such as += does not exist for that particular modification. Unfortunately, for very long variables, this requires writing out the full name on both sides of the equals sign — for instance, to negate a Bool, some.reallyLong.bool.variable = !some.reallyLong.bool.variable. This is unnecessarily verbose and impairs readability.
I propose the introduction of the keyword itself to refer to the LHS of an assignment on the RHS. This would allow e.g., some.reallyLong.boolean = !itself and some.reallyLong.int = itself * itself - 1.
Yes, with seems more appropriate for modifying instance members directly while itself would be used for applying operations or methods returning the same type (like sorted). Certainly possible with with, but less clear. In fact I think with would be better off being non-inout.
That was indeed the inspiration for this idea but being able to refer to the LHS on the RHS in any expression is useful in many other contexts, and is much cleaner than writing a one-off function. Some examples:
In general, new syntactic sugar is of the lowest priority in Swift's evolution; unless there is something truly astounding made possible, pitching a new keyword seems unlikely to meet with much success.
Just a warning. I don‘t remember if the pure function is bugged but a custom inout operator definetelly is bugged in Swift 4.1. I‘ll update this post when I‘ll be back at my workstation with a link to a bug-issue. There is a compiler bug related to inout which appears on a release build because of some aggressive optimizations and basically will crash your whole application.