<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 30, 2016, at 12:30, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">on Wed Jun 29 2016, Erica Sadun &lt;<a href="http://erica-at-ericasadun.com" class="">erica-AT-ericasadun.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On Jun 29, 2016, at 3:59 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">On Wed, Jun 29, 2016 at 4:50 PM, David Sweeris &lt;<a href="mailto:davesweeris@mac.com" class="">davesweeris@mac.com</a> &lt;<a href="mailto:davesweeris@mac.com" class="">mailto:davesweeris@mac.com</a>&gt;&gt; wrote:<br class="">That’s the “as proposed” usage for getting the size of a value (from<br class=""><a href="https://gist.github.com/erica/57a64163870486468180b8bab8a6294e" class="">https://gist.github.com/erica/57a64163870486468180b8bab8a6294e</a><br class=""></blockquote><br class=""><blockquote type="cite" class="">&lt;<a href="https://gist.github.com/erica/57a64163870486468180b8bab8a6294e" class="">https://gist.github.com/erica/57a64163870486468180b8bab8a6294e</a>&gt;)<br class="">// Types<br class="">MemoryLayout&lt;Int&gt;.size // 8 <br class="">MemoryLayout&lt;Int&gt;.arraySpacing // 8<br class="">MemoryLayout&lt;Int&gt;.alignment // 8<br class=""><br class="">// Value<br class="">let x: UInt8 = 5<br class="">MemoryLayout(x).dynamicType.size // 1<br class="">MemoryLayout("hello").dynamicType.arraySpacing // 24<br class="">MemoryLayout(29.2).dynamicType.alignment // 8<br class=""><br class=""><br class="">At least, I thought that was the latest version of the proposal. Maybe I’ve gotten confused.<br class=""><br class="">There must be a typo in these examples. `MemoryLayout(x.dynamicType).size` perhaps?<br class=""></blockquote><br class="">I have listened. I have updated.<br class=""><br class=""><a href="https://gist.github.com/erica/57a64163870486468180b8bab8a6294e" class="">https://gist.github.com/erica/57a64163870486468180b8bab8a6294e</a><br class=""><br class="">// Types<br class="">MemoryLayout&lt;Int&gt;.size // 8<br class="">MemoryLayout&lt;Int&gt;.arraySpacing // 8<br class="">MemoryLayout&lt;Int&gt;.alignment // 8<br class=""><br class="">// Value<br class="">let x: UInt8 = 5<br class="">MemoryLayout.of(x).size // 1<br class="">MemoryLayout.of(1).size // 8<br class="">MemoryLayout.of("hello").arraySpacing // 24<br class="">MemoryLayout.of(29.2).alignment // 8<br class=""></blockquote><br class="">I am still very skeptical that anyone needs the “Value” version, and as<br class="">long as we're resyntaxing I am inclined to take it away and see how many<br class="">people complain. &nbsp;You can still always write it yourself.</div></div></blockquote><br class=""></div><div>Sorry to only come across this now. The proposed implementation does not work.</div><div><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div>public&nbsp;static&nbsp;func&nbsp;of(_&nbsp;candidate&nbsp;:&nbsp;@autoclosure&nbsp;()&nbsp;-&gt;&nbsp;T)&nbsp;-&gt; MemoryLayout&lt;T&gt;.Type {</div><div>&nbsp; return&nbsp;MemoryLayout.init(candidate).dynamicType</div><div>}</div><div><br class=""></div><div>let value: Any = 2 // dynamicType is Int</div><div>let layout = MemoryLayout(value).dynamicType // inlined from above</div><div>let arrayType = [value].dynamicType</div><div><br class=""></div></blockquote><div>‘layout’ here is still 'MemoryLayout&lt;Any&gt;', not 'MemoryLayout&lt;Int&gt;', for the same reason that ‘arrayType’ is ‘Array&lt;Any&gt;’ rather than ‘Array&lt;Int&gt;’.</div><div><br class=""></div><div>If we want to support sizeofValue et al, we’d need to make these instance properties rather than static properties, and may then want to give up on the struct being generic.</div><div><br class=""></div><div>Jordan</div><br class=""></body></html>