<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=""><div><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">Isn’t this a short-term concern? I thought that requirement was going away.</div></div></div></blockquote><div><br class=""></div><div>AFAIK there are still concerns about ambiguity - [Int] - is it an array with one element (Int.self), or is it [Int].self?</div><br class=""><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">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></div></blockquote></div><br class=""></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=""></blockquote></div><br class=""></body></html>