<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">And following up to myself.<div class=""><br class=""></div><div class="">Please look here: <a href="https://github.com/erica/swift-evolution/blob/0f93c3c31b1d59358a61a5e2608dc71a598d9316/proposals/XXXX-sidestride.md" class="">https://github.com/erica/swift-evolution/blob/0f93c3c31b1d59358a61a5e2608dc71a598d9316/proposals/XXXX-sidestride.md</a><div class=""><br class=""></div><div class="">Plus, I fixed the typos in strideof/strideofValue's counts.</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 2, 2016, at 8:43 AM, Erica Sadun 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 style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Supporting Dave A, type-based calls are much more likely to be used than instance calls, unlike with dynamicType/type(of:)<div class=""><br class=""></div><div class=""><table style="box-sizing: border-box; border-spacing: 0px; border-collapse: collapse; margin-top: 0px; margin-bottom: 16px; display: block; width: 888px; overflow: auto; word-break: keep-all; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class=""><tbody style="box-sizing: border-box;" class=""><tr width="800" style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204);" class=""><th width="200" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">Term</th><th width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">stdlib search</th><th width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">gist search</th><th width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">Google site:github +swift</th></tr><tr width="800" style="box-sizing: border-box; background-color: rgb(248, 248, 248); border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204);" class=""><td width="200" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">sizeof</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">157</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">169</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">4880</td></tr><tr width="800" style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204);" class=""><td width="200" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">sizeofValue</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">4</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">34</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">584</td></tr><tr width="800" style="box-sizing: border-box; background-color: rgb(248, 248, 248); border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204);" class=""><td width="200" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">alignof</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">44</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">11</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">334</td></tr><tr width="800" style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204);" class=""><td width="200" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">alignofValue</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">5</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">5</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">154</td></tr><tr width="800" style="box-sizing: border-box; background-color: rgb(248, 248, 248); border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204);" class=""><td width="200" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">strideof</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">347</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">19</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">347</td></tr><tr width="800" style="box-sizing: border-box; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204);" class=""><td width="200" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">strideofValue</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">4</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">5</td><td width="150" style="box-sizing: border-box; padding: 6px 13px; border: 1px solid rgb(221, 221, 221);" class="">163</td></tr></tbody></table><div class="">Type-based calls like sizeof() are poor candidates for parameter labels. While it's acceptable to write sizeof(Int), but one must write size(of: Int.self) (with the trailing self) when the function has a label. For this reason, this proposal prefers using no-label calls for types (otherwise they would have been ofType) and labeled calls for values:</div></div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(51, 51, 51);" class=""><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">print</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">sizeof</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>)) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// works</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">print</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">sizeof</span>(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">self</span>)) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// works</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">withoutLabel</span><T>(thetype: T<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">Type</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-></span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">sizeof</span>(T) }
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">withLabel</span><T>(<span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">label</span> <span class="pl-smi" style="box-sizing: border-box;">label</span>: T<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">Type</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-></span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">sizeof</span>(T) }
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// Works</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">print</span>(withoutLabel(<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>))
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// Works</span>
<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">print</span>(withLabel(label: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">self</span>))
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// Does not work</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// error: cannot create a single-element tuple with an element label</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// print(withLabel(label: Int)) </span></pre><div class=""><br class=""></div></div><div class=""><br class=""></div><div class="">So with this in mind:</div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; margin-top: 0px; margin-bottom: 16px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; color: rgb(51, 51, 51);" class=""><code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; overflow: visible; line-height: inherit; word-wrap: normal;" class="">/// Returns the contiguous memory footprint of `T`.
///
/// Does not include any dynamically-allocated or "remote" storage.
/// In particular, `size(X.self)`, when `X` is a class type, is the
/// same regardless of how many stored properties `X` has.
public func size<T>(_: T.Type) -> Int
/// Returns the contiguous memory footprint of `T`.
///
/// Does not include any dynamically-allocated or "remote" storage.
/// In particular, `size(of: a)`, when `a` is a class instance, is the
/// same regardless of how many stored properties `a` has.
public func size<T>(of: T) -> Int
/// Returns the least possible interval between distinct instances of
/// `T` in memory. The result is always positive.
public func spacing<T>(_: T.Type) -> Int
/// Returns the least possible interval between distinct instances of
/// `T` in memory. The result is always positive.
public func spacing<T>(of: T) -> Int
/// Returns the minimum memory alignment of `T`.
public func alignment<T>(_: T.Type) -> Int
/// Returns the minimum memory alignment of `T`.
public func alignment<T>(of: T) -> Int</code></pre></div><div class="">-- E</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>