[swift-evolution] [Draft] Refining identifier and operator symbology (take 2)

Nevin Brackett-Rozinsky nevin.brackettrozinsky at gmail.com
Sun Feb 26 11:50:20 CST 2017


This looks very good Xiaodi, and I have a few thoughts about it.

First, is the intent that Swift will follow future changes to Unicode
operator recommendations, or that Swift will choose a “frozen in time” set
of Unicode recommendations to adopt? If the former, then we will likely see
source-breaking changes as Unicode evolves. And if the latter, then Swift’s
choices are apt to diverge even more from Unicode’s over time.

Second, it is well-established that programming operators do not have to be
mathematical. For example, Swift uses the punctuation marks ‘!’, ‘?’, and
‘&’ as operators in its standard library. The approach described in your
proposal does an excellent job at covering the core mathematical operator
characters in Unicode, however it does not appear to make such an effort
toward non-mathematical operators.

Of particular note, given that ‘?’, ‘¿’, and ‘‽’ are operator characters,
it seems inconsistent to omit ‘⸘’. Similarly, with ‘&’ an operator, one
would expect ‘⅋’ to be as well. I see that “expanding the set of operator
characters” is listed as a non-goal, however that does not make it an
anti-goal, and the proposal indeed expands the set by adding ‘\’. Likewise
“rectifying Unicode shortcomings” is listed as a non-goal, although the
proposal incorporates some 16 characters for Swift 3 compatibility.

Another point that may be worth considering, are the two specific
characters ‘∅’ and ‘∞’ which, although strongly mathematical, are
definitely not operators. They are names for things—objects, quantities—and
thus by the principle of least surprise they should be available for use in
identifier names. Just as one might write “let π = Double.pi” at the top of
a file, so too might one write “let ∞ = Double.infinity” or “let ∅ =
Set<Int>()” for use later on:

let y = sin(π * x)
if tan(θ) == ∞ { … }
var s = ∅

Thus, for the purpose of consistency, I think it makes sense to classify
‘∅’ and ‘∞’ as identifiers, as well as ‘⸘’ and ‘⅋’ as operators.
Alternatively, ‘∞’ could be a floating-point literal, in which case it
still would not be an operator.

I understand that you described this type of feedback (on particular
characters) as “less helpful”, however it appears that the “most helpful”
types of feedback are unnecessary: the proposal is well thought out, with a
strong core approach. It is only in the fine details that a few
improvements can be made, “lesser” though they may be.

Nevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170226/dc4a631e/attachment.html>


More information about the swift-evolution mailing list