[swift-evolution] [Proposal draft] Enhanced floating-point protocols

Dave Abrahams dabrahams at apple.com
Mon Apr 18 17:09:19 CDT 2016


on Thu Apr 14 2016, Stephen Canon <swift-evolution at swift.org> wrote:

> Hi Howard, thanks for the feedback.
>
>     On Apr 14, 2016, at 6:05 PM, Howard Lovatt <howard.lovatt at gmail.com> wrote:
>
>     +1 great addition.
>
>     Would suggest the naming could be more consistent, in particular:
>
>     1 Anything returning Self could be named xxxed. In the current proposal this
>       naming convention is sometimes used, e.g. divided, and sometimes not, e.g.
>       subtracting. Suggest all unified with the xxxed convention.
>
> The names in the Arithmetic protocol are Dave A’s creation, but I think they’re
> a reasonable compromise given the constraints placed on us. While consistency
> would be nice, I think that clarity at use site is more important, under the
> rationale that code is read more often than written. Also, keep in mind that in
> practice, “everyone” will use the operators for arithmetic. Dave may have more
> to say on the subject.
>
>     1 Anything returning Bool could be named isXxx. In some cases this is used,
>       e.g. isUnordered, but not others, e.g. totalOrder.

FWIW, that is a much more restrictive constraint than what our API guidelines
specify.  They say the usage should read as an assertion about the
receiver, e.g.

    person.hasTooManyCats
    waterSupply.containsUnsafeLevelsOfLead

are fine.

>
>
> That’s a reasonable point. isTotallyOrdered(with: ) is simple, but I’m not sure
> how I would handle totalOrderMagnitude( ) under this scheme. Thoughts?
>
> Thanks,
> – Steve
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-- 
Dave



More information about the swift-evolution mailing list