[swift-evolution] ed/ing, InPlace, Set/SetAlgebra naming resolution

Taras Zakharko taras.zakharko at uzh.ch
Fri Feb 12 07:41:12 CST 2016


I would like to warn agains attempts to use ‘grammar’ as justification for API design. The problem is that language is not just about following some particular rules of grammar. Language is all about convention, and grammar is essentially an optimisation technique that allows us to use convention more efficiently. Still, grammar is only one of the tools we have when communicating — the actual rules of language use are much more complicated. I am not sure  that every mathematician will immediately understand what you mean by ‘uniting two sets’ — because nobody uses that particular terminology. Now, ‘creating a union of two sets’ is a perfectly clear concept. Its not the grammatical form that conveys the meaning but what we conventionally associate with that particular form in that particular context. Union, intersection etc. are conventionally non-mutating concepts. All proposals for mutating concepts I have seen so far are not semantically transparent, because they do not follow the commonly accepted convention. The most appropriate names for those APIs I can come put with is something like

func replaceWithUnion(with: Self)
func replaceWithIntersection(with: Self)

or maybe

func unionUpdate(with: Self)
func intersectionUpdate(with: Self)

e.g. names that actually communicate what is going on. 

— Taras

> On 12 Feb 2016, at 14:23, Matthew Judge via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> 
> On Thu, Feb 11, 2016 at 4:27 PM, Rob Mayoff via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> On Thu, Feb 11, 2016 at 12:54 PM, Jim Hillhouse via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> The present participle of 'union' is technically speaking, 'unioning'. But it is not widely used. In fact, in both Pages and Word, 'unioning' is flagged as a misspelling of 'union'.
> 
> Outside of programming, "union" is a noun, not a verb, and "unite" is already a perfectly good verb that means "create the union of".  So why not
> 
>     func union(with other: Self) -> Self
>     func unite(with other: Self)
> 
>  
> My biggest problem with this diff is the different treatment of "union" and "intersection"... it is confusing that one is mutating and the other is non-mutating. They are both the same part of speech and both the term of art, so they should both have the same mutability implications.
> 
> I'd vote either of the following (leaning toward the first group because I think the term of art implies non-mutating):
> 
> func union(other: Self) -> Self
> func unite(other: Self)
> func intersection(other: Self) -> Self
> func intersect(other: Self)
> 
> func uniting(other: Self) -> Self
> func union(other: Self)
> func intersecting(other: Self) -> Self
> func intersection(other: Self)
> 
> unite and uniting are still reasonably close to union (exactly the same for the first 3 characters which should help with autocomplete discoverability).
> 
>  
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> 
> 
> _______________________________________________
> 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/20160212/d57017e3/attachment.html>


More information about the swift-evolution mailing list