<div dir="ltr"><div>On Thu, Apr 28, 2016 at 3:55 PM, Josh Parmenter via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br></div><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">I think this is a nice suggestion as well.<br>
Best,<br>
Josh<br>
<br>
On Apr 28, 2016, at 1:52 PM, Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&lt;mailto:<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;&gt; wrote:<br>
<span class=""><br>
<br>
On Apr 28, 2016, at 11:44 AM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&lt;mailto:<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;&gt; wrote:<br>
<br>
We all know and love sizeof(), but given that it&#39;s different from its C counterpart anyway, shouldn&#39;t these conform to Swift naming guidelines? In other words, after SE-0006, shouldn&#39;t these names be as follows?<br>
<br>
```<br>
size&lt;T&gt;(of: T.Type)<br>
size&lt;T&gt;(ofValue: T)<br>
stride&lt;T&gt;(of: T.Type)<br>
stride&lt;T&gt;(ofValue: T)<br>
align&lt;T&gt;(of: T.Type)<br>
align&lt;T&gt;(ofValue: T)<br>
```<br>
<br>
There are obvious issues with two different things named `stride`, but IMO that&#39;s best addressed by renaming one of them; the real problem is that the word stride is used in two different ways already. Thoughts?<br>
<br>
Seems reasonable to me.<br></span></blockquote><div><br></div><div><br></div>Well, glad that it&#39;s uncontroversial. Here&#39;s a draft of a short proposal then. Comments welcome:<div><br></div><h1 style="font-size:2.25em;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.2;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;margin-top:0px!important">Rename <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">sizeof(_:)</code> and related functions to follow API naming guidelines</h1><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px"><li style="">Proposal: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/NNNN-name.md" style="color:rgb(64,120,192);text-decoration:none;background-color:transparent">SE-NNNN</a></li><li style="">Author(s): <a href="https://github.com/xwu" style="color:rgb(64,120,192);text-decoration:none;background-color:transparent">Xiaodi Wu</a></li><li style="">Status: <span style="font-weight:bolder"><a href="https://github.com/xwu/swift-evolution/blob/master/proposals/NNNN-rename-sizeof.md#rationale" style="color:rgb(64,120,192);text-decoration:none;background-color:transparent">Awaiting review</a></span></li><li style="">Review manager: TBD</li></ul><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;"><a id="user-content-introduction" class="" href="https://github.com/xwu/swift-evolution/blob/master/proposals/NNNN-rename-sizeof.md#introduction" style="color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1;background-color:transparent"></a>Introduction</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px">With <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0006-apply-api-guidelines-to-the-standard-library.md" style="color:rgb(64,120,192);text-decoration:none;background-color:transparent">SE-0006</a>, Standard Library APIs have been renamed to follow a set of naming guidelines. However, <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">sizeof(_:)</code> and related functions do not follow these guidelines.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px">Since <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">sizeof(_:)</code> behaves differently in any case from <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">sizeof()</code> in other C-family languages, it makes sense to conform these functions to Swift naming guidelines.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px">Swift-evolution thread: [link goes here]</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;"><a id="user-content-proposed-solution" class="" href="https://github.com/xwu/swift-evolution/blob/master/proposals/NNNN-rename-sizeof.md#proposed-solution" style="color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1;background-color:transparent"></a>Proposed solution</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px">The proposed solution is to rename <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">sizeof(_:)</code> and related functions as follows:</p><div class="" style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px"><pre style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;padding:16px;overflow:auto;border-radius:3px;word-wrap:normal;background-color:rgb(247,247,247)"><span class="" style="color:rgb(167,29,93)">func</span> <span class="" style="color:rgb(121,93,163)">size</span>&lt;T&gt;(of: T<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(167,29,93)">Type</span>)   // currently: sizeof&lt;T&gt;(_: T<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(167,29,93)">Type</span>)
<span class="" style="color:rgb(167,29,93)">func</span> <span class="" style="color:rgb(121,93,163)">size</span>&lt;T&gt;(ofValue: T)   // currently: sizeofValue&lt;T&gt;(_: T)
<span class="" style="color:rgb(167,29,93)">func</span> <span class="" style="color:rgb(121,93,163)">stride</span>&lt;T&gt;(of: T<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(167,29,93)">Type</span>) // currently: strideof&lt;T&gt;(_: T<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(167,29,93)">Type</span>)
<span class="" style="color:rgb(167,29,93)">func</span> <span class="" style="color:rgb(121,93,163)">stride</span>&lt;T&gt;(ofValue: T) // currently: strideofValue&lt;T&gt;(_: T)
<span class="" style="color:rgb(167,29,93)">func</span> <span class="" style="color:rgb(121,93,163)">align</span>&lt;T&gt;(of: T<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(167,29,93)">Type</span>)  // currently: alignof&lt;T&gt;(_: T<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(167,29,93)">Type</span>)
<span class="" style="color:rgb(167,29,93)">func</span> <span class="" style="color:rgb(121,93,163)">align</span>&lt;T&gt;(ofValue: T)  // currently: alignofValue&lt;T&gt;(_: T)</pre></div><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;"><a id="user-content-detailed-design" class="" href="https://github.com/xwu/swift-evolution/blob/master/proposals/NNNN-rename-sizeof.md#detailed-design" style="color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1;background-color:transparent"></a>Detailed design</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px">With the renaming proposed above, <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">stride(of:)</code> will appear to be related to <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">stride(from:to:by:)</code>. This conflict arises from a pre-existing issue; namely, the term &quot;stride&quot; is used to mean two different things. Although moving the preposition only highlights the issue, one possible resolution is to rename <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">strideof(_:)</code> to <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">strideSize(of:)</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">strideofValue(_:)</code> to<code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;border-radius:3px;background-color:rgba(0,0,0,0.0392157)">strideSize(ofValue:)</code>.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;"><a id="user-content-impact-on-existing-code" class="" href="https://github.com/xwu/swift-evolution/blob/master/proposals/NNNN-rename-sizeof.md#impact-on-existing-code" style="color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1;background-color:transparent"></a>Impact on existing code</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px">The proposed changes are as source-breaking for current code as the set of changes implemented for SE-0006. During implementation, previous names can be annotated as unavailable symbols to allow the proper Fix-Its to be emitted by the compiler.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;"><a id="user-content-alternatives-considered" class="" href="https://github.com/xwu/swift-evolution/blob/master/proposals/NNNN-rename-sizeof.md#alternatives-considered" style="color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1;background-color:transparent"></a>Alternatives considered</h2><div><span style="color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;line-height:25.6px">The alternative is to maintain current function names.</span> </div></div></div></div>