<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 2, 2016, at 3:35 PM, Tony Allevato 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 dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Jun 2, 2016 at 2:25 PM Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On the other hand, on its own sizeof() is not unsafe, and so the argument that it should be longer to call attention to itself (by analogy with UnsafePointer) isn't quite apt.<br class=""><br class="">And I'm not sure we really want to encourage anyone else to be defining a global function named size(of:) anyway, so I wouldn't consider vacating that name for end-user purposes to be a meaningful positive.<br class=""></blockquote><div class=""><br class=""></div><div class="">I was thinking more of situations where someone is in a scope (such as a method in a struct or class) that has its own size(of:) method but also needs to do something with the global size(of:) and now has to distinguish the two. I'll admit that the likelihood of all of those stars aligning is probably rare, though.</div><div class=""><br class=""></div><div class="">That being said, I see no reason to choose a very general name over one that is far more descriptive. We should optimize for the N times an expression is read instead of the one time it's written.</div></div></div></div></blockquote><br class=""></div><div><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-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns the contiguous memory footprint of `T`.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Does not include any dynamically-allocated or "remote" storage.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// In particular, `memorySize(ofType: X.self)`, when `X` is a class type, is the</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// same regardless of how many stored properties `X` has.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</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);">memorySize</span> <T>(ofType: 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-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns the contiguous memory footprint of `T`.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Does not include any dynamically-allocated or "remote" storage.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// In particular, `memorySize(of: a)`, when `a` is a class instance, is the</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// same regardless of how many stored properties `a` has.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</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);">memorySize</span> <T>(of: T) <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-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns the least possible interval between distinct instances of</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// `T` in memory. The result is always positive.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</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);">memoryInterval</span><T>(ofType: 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-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns the least possible interval between distinct instances of</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// `T` in memory. The result is always positive.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</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);">memoryInterval</span> <T>(of: T) <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-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns the minimum memory alignment of `T`.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</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);">memoryAlignment</span><T>(ofType: 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-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// Returns the minimum memory alignment of `T`.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</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);">memoryAlignment</span> <T>(of: T) <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></pre><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><a href="https://github.com/erica/swift-evolution/blob/sizestride/proposals/XXXX-sidestride.md" class="">https://github.com/erica/swift-evolution/blob/sizestride/proposals/XXXX-sidestride.md</a></div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div></div><br class=""></body></html>