SetAlgebra naming update


(Thorsten Seitz) #1

That’s certainly an improvement, but why “formIntersection” instead of “intersect” (in analogy to “subtract”)?

-Thorsten

···

Am 30. März 2016 um 00:07 schrieb “T.J. Usiyan via swift-evolution” swift-evolution@swift.org:

I think that this is a great improvement and is consistent enough to accept. form will take some getting used to.
TJ

On Thu, Mar 24, 2016 at 9:39 PM, Dave Abrahams via swift-evolution swift-evolution@swift.org wrote:

Just an update:

The naming guidelines working group went back into negotiation over
the shape of SetAlgebra (and thus, Set and OptionSet) for
Swift 3, and reached a new consensus. We intend to bring forward a
proposal for the API shown here:

http://dabrahams.github.io/swift-naming/SetAlgebra-Math.html

and to update the guidelines to suggest using the “form” prefix to
create a verb phrase for a mutating method when the operation is
fundamentally non-mutating and described by a noun.

Regards,


Dave


swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Dave Abrahams) #2

That's certainly an improvement, but why "formIntersection" instead of
"intersect" (in analogy to "subtract")?

1. Consistency with union, which is more closely related than subtract.

2. "Intersect" actually has the wrong meaning as an imperative. If you
   tell set A to intersect set B, and then ask whether A intersects B
   (!A.isDisjoint(with: B)), you would expect an answer of true.

···

on Wed Mar 30 2016, Thorsten Seitz <tseitz42-AT-icloud.com> wrote:

-Thorsten

Am 30. März 2016 um 00:07 schrieb "T.J. Usiyan via swift-evolution" <swift-evolution@swift.org>:

    I think that this is a great improvement and is consistent enough to accept. `form` will take some getting used to.
    TJ

    On Thu, Mar 24, 2016 at 9:39 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote:

        Just an update:

        The naming guidelines working group went back into negotiation over
        the shape of SetAlgebra (and thus, Set and OptionSet) for
        Swift 3, and reached a new consensus. We intend to bring forward a
        proposal for the API shown here:

        http://dabrahams.github.io/swift-naming/SetAlgebra-Math.html

        and to update the guidelines to suggest using the "form" prefix to
        create a verb phrase for a mutating method when the operation is
        fundamentally non-mutating and described by a noun.

        Regards,

        --
        Dave

        _______________________________________________
        swift-evolution mailing list
        swift-evolution@swift.org
        https://lists.swift.org/mailman/listinfo/swift-evolution

    _______________________________________________
    swift-evolution mailing list
    swift-evolution@swift.org
    https://lists.swift.org/mailman/listinfo/swift-evolution

--
Dave


(Thorsten Seitz) #3

That's certainly an improvement, but why "formIntersection" instead of
"intersect" (in analogy to "subtract")?

1. Consistency with union, which is more closely related than subtract.

I'd prefer consistency with the verb rule here (using formXXX only as last resort).

2. "Intersect" actually has the wrong meaning as an imperative. If you
  tell set A to intersect set B, and then ask whether A intersects B
  (!A.isDisjoint(with: B)), you would expect an answer of true.

Sorry, but I do not agree. With that reasoning I would have to expect a.intersection(b) to be not empty.

-Thorsten

···

Am 30.03.2016 um 16:49 schrieb Dave Abrahams <dabrahams@apple.com>:

on Wed Mar 30 2016, Thorsten Seitz <tseitz42-AT-icloud.com> wrote:


(Dave Abrahams) #4

That's certainly an improvement, but why "formIntersection" instead of
"intersect" (in analogy to "subtract")?

1. Consistency with union, which is more closely related than subtract.

I'd prefer consistency with the verb rule here

Which rule is that? As far as I can tell, this is consistent with all
the rules.

(using formXXX only as last resort).

Though I prefer not to, you can look at this as a last resort if you
like; the alternative you're proposing has the wrong implication, so it
is not a candidate. It would be like using “remainder” as a verb for
integers. Yes, it's a legitimate verb, but it means the wrong thing
(see retail).

2. "Intersect" actually has the wrong meaning as an imperative. If you
  tell set A to intersect set B, and then ask whether A intersects B
  (!A.isDisjoint(with: B)), you would expect an answer of true.

Sorry, but I do not agree. With that reasoning I would have to expect
a.intersection(b) to be not empty.

Yes, that's exactly what I'm saying. If you tell A to intersect B,
presumably when the call completes, A intersects B (i.e. has a non-empty
intersection). That would imply an implementation like, e.g.

  mutating func intersect(other: Self) {
    self.formUnion(other)
  }
                   
which is almost the opposite of the desired implication.

···

on Wed Mar 30 2016, Thorsten Seitz <tseitz42-AT-icloud.com> wrote:

Am 30.03.2016 um 16:49 schrieb Dave Abrahams <dabrahams@apple.com>:

on Wed Mar 30 2016, Thorsten Seitz <tseitz42-AT-icloud.com> wrote:

--
Dave