<div><div><div class="gmail_quote"><div dir="auto">On Mon, Oct 2, 2017 at 19:28 Ethan Tira-Thompson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div>I’m all for fixing pressing issues requested by Xiaodi, but beyond that I request we give a little more thought to the long term direction.</div><div><br></div>My 2¢ is I’ve been convinced that very few characters are “obviously” either a operator or identifier across all contexts where they might be used.  Thus relegating the vast majority of thousands of ambiguous characters to committee to decide a single global usage.  But that is both a huge time sink and fundamentally flawed in approach due to the contextual dependency of who is using them.<div><br></div><div>For example, if a developer finds a set of symbols which perfectly denote some niche concept, do you really expect the developer to submit a proposal and wait months/years to get the characters classified and then a new compiler version to be distributed, all so that developer can adopt his/her own notation?</div></div></blockquote><div dir="auto"><br></div></div></div></div><div><div><div class="gmail_quote"><div dir="auto">The Unicode Consortium already has a document describing which Unicode characters are suitable identifiers in programming languages, with guidance as to how to customize that list around the edges. This is already adopted by other programming languages. So, with little design effort, that task is not only doable but largely done.</div><div dir="auto"><br></div><div dir="auto">As to operators, again, I am of the strong opinion that making it possible for developers to adopt any preferred notation for any purpose (a) is fundamentally incompatible with the division between operators and identifiers, as I believe you’re saying here; and (b) should be a non-goal from the outset. The only task, so far as I can tell, left to do is to identify what pragmatic set of (mostly mathematical) symbols are used as operators in the wider world and are likely to be already used in Swift code or part of common use cases where an operator is clearly superior to alternative spellings. In my view, the set of valid operator characters not only shouldn’t require parsing or import directives, but should be small enough to be knowable by memory.</div></div></div></div><div><div><div class="gmail_quote"><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div>And then after that is done, now say a member of some distant tribe complains they wanted to use one of those characters to write identifiers using their native language.  Even though there may be zero intersection between these two user groups, this path forces Swift itself to pick a side of one vs. the other.</div><div><br></div><div><div>Surely there is some way to enable the local developer to resolve these choices rather than putting the swift language definition on the critical path?</div><div><br></div><div>The goals I know of:</div><div>1. Performance: don’t require parsing all imports to get the operator set</div><div>2. Security: don’t let imports do surprising/obfuscated stuff</div><div>3. Functionality: do let users write what they want, or import/share libraries for niche domains</div><div>4. Well defined: resolve conflicts, e.g. between libraries</div><div><div><div><br></div><div></div></div><div></div></div><div>I’m a little out of my league, but let’s say we want to use operator ᵀ from some matrixlib, how about:</div><div><span class="m_3874474793110052388m_-6249828287153355791Apple-tab-span" style="white-space:pre-wrap">        </span>import matrixlib (operator: ᵀ)</div><div><br></div><div>Or if you want several operators:</div><div><div><span class="m_3874474793110052388m_-6249828287153355791Apple-tab-span" style="white-space:pre-wrap">        </span>import matrixlib (operators: [ᵀ,·,⊗])</div><div><br></div><div>Ideally, any local operator definitions “just work” across their own module, but if it requires a “import (operator: ×)” in each file for performance, so be it.</div><div><br></div><div><div>A whitelist of “standard” operators would automatically import (i.e. initialize the operator character list) to maintain compatibility with current usage.  But you can imagine additional arguments to the import call, such as “standardOperators: false” to import only the explicitly listed operators and reduce potential surprises.</div><div><br></div><div>My rationale vs. the goals:</div></div><div>1. Performance: the operator character set vs. identifiers (everything else) can be determined within the file itself</div><div>2. Security: developer explicitly opts-in to the special operators they want to use, and readers can see where an operator comes from</div><div>3. Functionality: user is able to define their operators without getting committee involved</div><div>4. Well defined: potential conflict between libraries resolved by client’s choice to import or exclude the operator</div><div><br></div><div>Does this have potential?</div></div></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><div><div><br></div><div>-Ethan</div><div><br></div></div></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><div><div><blockquote type="cite"><div>On Oct 2, 2017, at 10:59 AM, David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_3874474793110052388m_-6249828287153355791Apple-interchange-newline"></blockquote></div></div></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><div><div><blockquote type="cite"><div><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><br class="m_3874474793110052388m_-6249828287153355791Apple-interchange-newline">On Oct 2, 2017, at 09:14, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite">What is your use case for this?<br><br><div class="gmail_quote"><div>On Mon, Oct 2, 2017 at 10:56 David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><br><div>On Oct 1, 2017, at 22:01, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><br><div><blockquote type="cite"><div>On Oct 1, 2017, at 9:26 PM, Kenny Leung via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_3874474793110052388m_-6249828287153355791m_8138847825612054131Apple-interchange-newline"><div><div style="word-wrap:break-word"><div>Hi All.</div><div><br></div><div>I’d like to help as well. I have fun with operators.</div><div><br></div><div>There is also the issue of code security with invisible unicode characters and characters that look exactly alike.</div></div></div></blockquote><div><br></div><div>Unless there is a compelling reason to add them, I think we should ban invisible characters.  What is the harm of characters that look alike?</div></div></blockquote><br></div><div dir="auto"><div>Especially if people want to use the character in question as both an identifier and an operator: We can make the character an identifier and its lookalike an operator (or the other way around).</div></div></blockquote></div></blockquote><div><br></div><div>Off the top of my head...</div><div>In calculus, “𝖽” (MATHEMATICAL SANS-SERIF SMALL D) would be a fine substitute for &quot;d&quot; in “𝖽y/𝖽x” (&quot;the derivative of y(x) with respect to x&quot;).</div><div>In statistics, we could use &quot;𝖢&quot; (MATHEMATICAL SANS-SERIF CAPITAL C), as in &quot;5𝖢3&quot; to mimic the &quot;<span style="font-size:8px;vertical-align:-1px"><sub>5</sub></span><span style="line-height:normal">C</span><span style="font-size:8px;vertical-align:-1px"><sub>3</sub></span>&quot; notation (&quot;5 choose 3&quot;). And although not strictly an issue of identifiers vs operators, “!” (FULLWIDTH EXCLAMATION MARK) would be an ok substitution (that extra space on the right looks funny) for &quot;!&quot; in “4!” (&quot;4 factorial&quot;).</div><div><br></div><div>I&#39;m sure there are other examples from math/science/&lt;insert any &quot;symbology&quot;-heavy DSL here&gt;, but “d” in particular is one that I’ve wanted for a while since Swift classifies &quot;∂&quot; (the partial derivative operator) as an operator rather than an identifier, making it impossible to use a consistent syntax between normal derivatives and partial derivatives (normal derivatives are &quot;d(y)/d(x)&quot;, whereas partial derivatives get to drop the parens &quot;∂y/∂x&quot;)</div><div><br></div><div>- Dave Sweeris</div></div></div></blockquote></div></div></div></div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><div><div><blockquote type="cite"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></div></div></div></div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div></div>