<div dir="ltr">On Thu, Apr 13, 2017 at 7:55 PM, Brent Royal-Gordon <span dir="ltr">&lt;<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><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 style="word-wrap:break-word"><span class="gmail-"><div><blockquote type="cite"><div>On Apr 13, 2017, at 4:48 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="gmail-m_9083929276519824393Apple-interchange-newline"><div><blockquote class="gmail_quote" 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;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 style="word-wrap:break-word"><div><div>You say &quot;this is the example set by `print`&quot;, but I don&#39;t think anything else actually *follows* that example. No other I/O operation in Swift behaves this way.</div></div></div></blockquote><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"><br></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">To be more accurate, it&#39;s not `print` that specifies this behavior, but rather the standard output stream&#39;s implementation of `TextOutputStream.write(_:)`. Swift *explicitly* leaves this choice up to the TextOutputStream-conforming type. That is, the behavior is up to the receiver and not the argument of a call to `TextOutputStream.write(_:)`.</div></div></blockquote><br></div></span><div>I feel like I must be misunderstanding what you&#39;re trying to say here, because I *think* what you&#39;re trying to say is that `TextOutputStream.write(_:)` is what decides whether to add the terminator, which is not only totally wrong (see <a href="https://github.com/apple/swift/blob/adc54c8a4d13fbebfeb68244bac401ef2528d6d0/stdlib/public/core/Print.swift#L260" target="_blank">https://github.com/apple/<wbr>swift/blob/<wbr>adc54c8a4d13fbebfeb68244bac401<wbr>ef2528d6d0/stdlib/public/core/<wbr>Print.swift#L260</a>) but doesn&#39;t even make any sense since there&#39;s a terminator parameter on `print` but none on `write(_:)`.</div></div></blockquote><div><br></div><div>Hmm, you&#39;re right here with respect to `print()`. It is, however, explicitly contemplated in the documentation for `TextOutputStream.write(_:)` that conforming types can also determine whether or not to append a terminator, and which, inside their implementation of `write`. The example given in the documentation is:</div><div><br></div><div>```</div><div><div>struct ASCIILogger: TextOutputStream {</div><div>    mutating func write(_ string: String) {</div><div>        let ascii = string.unicodeScalars.lazy.map { scalar in</div><div>            scalar == &quot;\n&quot;</div><div>              ? &quot;\n&quot;</div><div>              : scalar.escaped(asASCII: true)</div><div>        }</div><div>        print(ascii.joined(separator: &quot;&quot;), terminator: &quot;&quot;)</div><div>    }</div><div>}</div></div><div>```</div><div><br></div><div><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 style="word-wrap:break-word"><span class="gmail-HOEnZb"><font color="#888888"><br><div>
<span class="gmail-m_9083929276519824393Apple-style-span" style="border-collapse:separate;color:rgb(0,0,0);font-family:helvetica;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div style="font-size:12px">-- </div><div style="font-size:12px">Brent Royal-Gordon</div><div style="font-size:12px">Architechies</div></div></span>

</div>
<br></font></span></div></blockquote></div><br></div></div>