[swift-evolution] [Review] SE-0023 API Design Guidelines

Jacob Bandes-Storch jtbandes at gmail.com
Sat Jan 23 14:46:45 CST 2016


On Sat, Jan 23, 2016 at 12:44 PM, J. Cheyo Jimenez via swift-evolution <
swift-evolution at swift.org> wrote:

> The inPlace proposal is excellent. As suggested something like
> x.=f() would be perfect to distinguish mutating methods .Something I don't
> like from the API design guidelines is that non mutating methods like
> enumerate would be become enumerated. In my mind enumerate is a word of art
> and I don't ever think of it as muting so having to always use enumerated
> in the future seems weird. Also having to ed/ing non mutating methods seems
> to make mutating methods more important.
>
> //non mutating suggestion
> x.sort()
> x.split()
>
> //other ideas for mutating methods names
> x.sort*()
> x.sort&() // I like & the most
> x.split&()
> x.sort@()
>
> By marking a method with a special character at the end, the reader would
> know that the method mutates.
>

Ruby uses ! for this, by convention:
http://stackoverflow.com/questions/612189/why-are-exclamation-marks-used-in-ruby-methods
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160123/e710c48f/attachment.html>


More information about the swift-evolution mailing list