[swift-evolution] [Review] SE-0077 v2: Improved operator declarations

Dmitri Gribenko gribozavr at gmail.com
Thu Jul 7 11:23:57 CDT 2016


> Proposal link:
>
>
https://github.com/apple/swift-evolution/blob/master/proposals/0077-operator-precedence.md

Dave, Max and I discussed SE-0077 and reviewed the names of precedence
groups.
Here's our recommendation.

In general, we think some names don't read well and have some ambiguities,
for
example, "LogicalAndPrecedence" (looks like a conjunction),
"AdditivePrecedence" ("additive" is an adjective that modifies
"precedence"),
"RangePrecedence" ("range" is not an adjective, stands out).

We think that two directions would be fruitful:

1.  If the names of precedence groups will be in the same namespace as
types,
    then we recommend pushing the names of precedence groups into a
"namespace",
    for example "Precedence.Assignment".

2.  If (1) is not workable, we suggest incrementally improving existing
names
    to make them more readable and less ambiguous.  We think that making the
    names less technical by naming the groups after a representative
operation
    will be easier for users to understand (instead of "AdditivePrecence" we
    are proposing "AdditionPrecedence").  We also think that using an
adjective
    before "Precedence" does not read well in many cases
    ("NilCoalescingPrecedence": precedence that coalesces nils).


Current name            | Namespacing                 | Incremental
improvement
------------------------|-----------------------------|-----------------------------
AssignmentPrecedence    | Precedence.Assignment       | no change
TernaryPrecedence       | Precedence.Ternary          | no change
DefaultPrecedence       | Precedence.Default          | no change
LogicalOrPrecedence     | Precedence.LogicalOr        |
DisjunctionPrecedence
LogicalAndPrecedence    | Precedence.LogicalAnd       |
ConjunctionPrecedence
ComparativePrecedence   | Precedence.Comparison       | ComparisonPrecedence
NilCoalescingPrecedence | Precedence.NilCoalescing    | no change
CastPrecedence          | Precedence.Casting          | no change
RangePrecedence         | Precedence.RangeForming     |
RangeFormationPrecedence
AdditivePrecedence      | Precedence.Addition         | AdditionPrecedence
MultiplicativePrecedence| Precedence.Multiplication   |
MultiplicationPrecedence
BitwiseShiftPrecedence  | Precedence.BitwiseShift     |
BitwiseShiftPrecedence

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160707/0f71dd94/attachment.html>


More information about the swift-evolution mailing list