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

Dave Abrahams dabrahams at apple.com
Mon Apr 25 13:50:28 CDT 2016


on Mon Apr 25 2016, Radosław Pietruszewski <radexpl-AT-gmail.com> wrote:

> Q: Would it be possible to allow some sigil in method names (say, prefix/postfix
> `=`) without any automatic/magic treatment of these methods?

Almost anything is possible ;-).

> In Ruby, after all, postfix `!` is just allowed in names. It doesn’t have any
> semantic meaning for the interpreter, it’s just the (strong, well agreed upon)
> convention to use it to mark mutating methods in mutating/non-mutating pairs,
> like `foo.map(…)` vs `foo.map!(…)`.
>
> It works out well for Ruby. Would it be out of question to allow the same thing
> in Swift? A naming convention (`foo.sort()` vs `foo.sort=()`), not an automatic
> language feature?

I don't think we'd want to allow this without tying it to mutation; just IMO.

-- 
Dave


More information about the swift-evolution mailing list