<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 31, 2017, at 4:54 PM, Dave DeLong <<a href="mailto:delong@apple.com" class="">delong@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div 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; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Aug 31, 2017, at 5:45 PM, David Sweeris <<a href="mailto:davesweeris@mac.com" class="">davesweeris@mac.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" 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; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Aug 31, 2017, at 3:17 PM, Dave DeLong <<a href="mailto:delong@apple.com" class="">delong@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" 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; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Aug 31, 2017, at 3:58 PM, David Sweeris <<a href="mailto:davesweeris@mac.com" class="">davesweeris@mac.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Aug 31, 2017, at 2:51 PM, Dave DeLong via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Just a side observation…<div class=""><br class=""></div><div class="">One of the downsides I would put forward to notation like this is it massively increases the barrier to entry for anyone else. I look at that “Reduction.agda” file and wonder if I need to go back to school for a degree in Math just to understand what’s going on.</div><div class=""><br class=""></div><div class="">On the other hand, while using inefficient matrix notation may be more verbose, it<span class="Apple-converted-space"> </span><i class="">is</i> consistent with the other notation used in programming, which means it is more easily understandable for new-comers to the code.</div></div></div></blockquote><br class=""></div><div class="">New-comers from where? I've met more than one mathematician or physicist who claims they can't code because the syntax isn't what they're used to. People with different backgrounds can and do have vastly different ideas about what constitutes an intuitive syntax for any given semantic (which why I disagree with the notion that having more than one spelling for stuff is inherently bad).</div></div></div></blockquote><br class=""></div><div class="" 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; -webkit-text-stroke-width: 0px;">That’s a fair point, which IMO reinforces the notion that changes like this should be an editor-level feature, and not a code-level feature.</div><div class="" 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; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" 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; -webkit-text-stroke-width: 0px;">An editor can reformat code (using a font with bazillions of ligatures or whatever) in was that you wouldn’t want to necessarily “hard code”.</div></div></blockquote><br class=""></div><div class="" 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; -webkit-text-stroke-width: 0px;">To clarify, you're suggesting we do something like this?</div><div class="" 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; -webkit-text-stroke-width: 0px;"><div class="" style="margin: 0px; line-height: normal; font-family: 'Fantasque Sans Mono'; background-color: rgb(0, 57, 70);"><font size="4" class=""><font color="#d55194" class="">@<span class="" style="text-decoration: underline;">p</span>rettyprint</font><font color="#a4b0b1" class="">(</font><font color="#de5194" class="">prefix operator</font><font color="#a4b0b1" class=""> </font><span class="" style="color: rgb(215, 96, 27);">"Σ"</span><span class="" style="color: rgb(164, 176, 177);">,<span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(106, 129, 136);">/*probably some CSS or something for telling the editor where to position the arguments relative to the operator, whether they're rendered with subscript vs superscript vs normal, etc */</span><span class="" style="color: rgb(164, 176, 177);">)</span></font></div><div class="" style="margin: 0px; line-height: normal; font-family: 'Fantasque Sans Mono'; color: rgb(164, 176, 177); background-color: rgb(0, 57, 70);"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><font size="4" class=""><span class="" style="color: rgb(222, 81, 148);">func</span><span class="Apple-converted-space"> </span>sum <T:<span class="Apple-converted-space"> </span><span class="" style="color: rgb(127, 135, 207);">Numeric</span>, S:<span class="Apple-converted-space"> </span><span class="" style="color: rgb(127, 135, 207);">Sequence</span>> (indicies:<span class="Apple-converted-space"> </span><span class="" style="color: rgb(127, 135, 207);">S</span>, term: (<span class="" style="color: rgb(127, 135, 207);">S</span>.<span class="" style="color: rgb(127, 135, 207);">Element</span>) -><span class="Apple-converted-space"> </span><span class="" style="color: rgb(127, 135, 207);">T</span>) -><span class="Apple-converted-space"> </span><span class="" style="color: rgb(127, 135, 207);">T</span><span class="Apple-converted-space"> </span>{</font></div><div class="" style="margin: 0px; line-height: normal;"><font size="4" class=""> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(222, 81, 148);">return</span><span class="Apple-converted-space"> </span>indicies.<span class="" style="color: rgb(44, 158, 219);">reduce</span>(<span class="" style="color: rgb(229, 73, 61);">0</span>) { $0 + term($1) }</font></div><div class="" style="margin: 0px; line-height: normal;"><font size="4" class="">}</font></div></div></div></div><div class=""><br class=""></div><div class="">Technically speaking, yeah, sure, such a system<span class="Apple-converted-space"> </span><i class="">could</i><span class="Apple-converted-space"> </span>be made to work. I don't see it getting much support outside of Xcode, though, unless you can convince other languages to adopt the same convention. We'd want people's choice of display style to be driven by personal preference, not whether they can integrate Xcode into their workflow. Speaking of workflows, how far from "plain text" do you think we can get before people start thinking that you need a mac running Xcode to program in Swift?</div><div class=""><br class=""></div><div class="">- Dave Sweeris</div></div></div></blockquote><br class=""></div><div 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; -webkit-text-stroke-width: 0px;" class="">Perhaps… I’m fully admitting up-front that this is all really hand-wavy and we’re probably veering a bit off-topic, since this is getting more in to “editor-evolution” rather than “swift-evolution”.</div><div 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; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div 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; -webkit-text-stroke-width: 0px;" class="">But yes, if an editor had some sort of intrinsic knowledge about the purpose of a line of code, then it could visually “rewrite” a summation function using a Σ. Or if it knew about matrix types, perhaps it could render the matrix in the 2D format that is standard to matrix notation. Or it could replace UIImage(named: “someConstant”) with the rendered image literal, without actually requiring the explicit underlying image literal syntax.</div><div 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; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div 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; -webkit-text-stroke-width: 0px;" class="">A grossly simplified comparison is that good markdown editors don’t just show the plaintext for the markdown you’re writing, but will also<font face="Menlo" class=""><span class="" style="font-size: 11px;"><span class="Apple-converted-space"> </span>`stylize`</span></font><span class="Apple-converted-space"> </span><i class="">*code*</i><span class="Apple-converted-space"> </span><b class="">_correctly_</b><span class="Apple-converted-space"> </span><b class="">**as**</b><span class="Apple-converted-space"> </span><i class="">*<font face="Menlo" class=""><span class="" style="font-size: 11px;">`you write it`</span></font>*</i>.</div></div></blockquote><br class=""></div><div><div>Aside from the bits about matrices and other things that drastically change the line height, the I think that comparison is only <i class="">grossly</i> simplified from the PoV of an editor's author(s).</div><div><br class=""></div><div>What about the issue of different spelling conventions? It's all well and good for the editor to display "pow(x, 2)" as "x²", but I've never used a system where something that's <i class="">displayed</i> as "x²" isn't <i class="">typed</i> as "x^2" (of course, now that I've said that, someone will probably come up with 53 counter-examples). If the editor is rendering a line of code like "let y = log₃(sin²(∫x³dx))" and I add a "+ x^2" to the end, it's probably going to take me a while to find the bug because years of math nerdery (sp?) have trained my brain to think that, when I'm "mathing", "x^2" and "x²" are equivalent statements, kinda like they're just written in different fonts or something. Now, clearly the fault would be mine (because, despite all the math symbols, I'd be programming, not mathing), but if we were to get such a system, I bet that mistake would make the list of "Top 10 Bugs Math People Create in Swift", and it it feels antithetical to a language that generally goes out of its way to prevent such simple errors. The only practical solution I can think of is a mechanism for importing a library <i class="">without</i> its operators (and preferably without a subset of its operators, since a scenario where someone would need `1+2` to mean something other than `3` seems <i class="">extremely</i> niche).</div><div><br class=""></div><div>- Dave Sweeris</div></div><br class=""></body></html>