<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="">Agreed. Also, if we’re supposed to say `MemoryLayout.of()` now, does MemoryLayout still need a public init? Half of the proposal’s problems revolve around the likely-unexpected behavior caused by passing T.self to the init function (although, argument labels would also solve the issue).<div class=""><br class=""></div><div class="">- Dave Sweeris</div><div class=""><br class=""><div class="">On Jun 29, 2016, at 10:05 PM, Jacob Bandes-Storch via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I'm not sure this bikeshed is the right color yet.<br class=""><div class=""><br class=""></div><div class="">How does the user remember the distinction between MemoryLayout<Int> and MemoryLayout.of(Int) ? To keep it clear, how about ofValue() rather than of() ?</div><div class=""><br class=""></div><div class="">Also, could the implementation be simply</div><div class=""><br class=""></div><div class=""> static func ofValue(_ value: @autoclosure () -> T) -> MemoryLayout<T>.Type {</div><div class=""> return self</div><div class=""> }</div><div class=""><br class=""></div><div class="">?</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div data-smartmail="gmail_signature" class=""><div dir="ltr" class=""><div class="">Jacob<br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Wed, Jun 29, 2016 at 7:36 PM, Erica Sadun via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><span class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 29, 2016, at 3:59 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 29, 2016 at 4:50 PM, David Sweeris <span dir="ltr" class=""><<a href="mailto:davesweeris@mac.com" target="_blank" class="">davesweeris@mac.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">That’s the “as proposed” usage for getting the size of a value (from <a href="https://gist.github.com/erica/57a64163870486468180b8bab8a6294e" target="_blank" class="">https://gist.github.com/erica/57a64163870486468180b8bab8a6294e</a>) <div class=""><pre style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;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 style="color:rgb(150,152,150)" class="">// Types</span>
MemoryLayout<span style="color:rgb(167,29,93)" class=""><</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">>.</span>size <span style="color:rgb(150,152,150)" class="">// 8 </span>
MemoryLayout<span style="color:rgb(167,29,93)" class=""><</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">>.</span>arraySpacing <span style="color:rgb(150,152,150)" class="">// 8</span>
MemoryLayout<span style="color:rgb(167,29,93)" class=""><</span><span style="color:rgb(0,134,179)" class="">Int</span><span style="color:rgb(167,29,93)" class="">>.</span>alignment <span style="color:rgb(150,152,150)" class="">// 8</span>
<span style="color:rgb(150,152,150)" class="">// Value</span>
<span style="color:rgb(167,29,93)" class="">let</span> x: <span style="color:rgb(0,134,179)" class="">UInt8</span> <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(0,134,179)" class="">5</span>
MemoryLayout(x)<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">dynamicType</span><span style="color:rgb(167,29,93)" class="">.</span>size <span style="color:rgb(150,152,150)" class="">// 1</span>
MemoryLayout(<span style="color:rgb(24,54,145)" class=""><span class="">"</span>hello<span class="">"</span></span>)<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">dynamicType</span><span style="color:rgb(167,29,93)" class="">.</span>arraySpacing <span style="color:rgb(150,152,150)" class="">// 24</span>
MemoryLayout(<span style="color:rgb(0,134,179)" class="">29</span><span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(0,134,179)" class="">2</span>)<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">dynamicType</span><span style="color:rgb(167,29,93)" class="">.</span>alignment <span style="color:rgb(150,152,150)" class="">// 8</span></pre><div class=""><br class=""></div><div class=""><br class=""></div>At least, I <i class="">thought</i> that was the latest version of the proposal. Maybe I’ve gotten confused.</div></div></blockquote><div class=""><br class=""></div><div class="">There must be a typo in these examples. `MemoryLayout(x.dynamicType).size` perhaps?</div></div></div></div></div></blockquote><br class=""></div></span><div class="">I have listened. I have updated.</div><div class=""><br class=""></div><div class=""><a href="https://gist.github.com/erica/57a64163870486468180b8bab8a6294e" target="_blank" class="">https://gist.github.com/erica/57a64163870486468180b8bab8a6294e</a></div><div class=""><br class=""></div><div class=""><span class=""><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">// Types</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span class="">MemoryLayout</span><span style="" class=""><</span><span style="color:#703daa" class="">Int</span><span style="" class="">>.</span><span class="">size</span><span style="" class=""> </span><span style="color:#008400" class="">// 8</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span class="">MemoryLayout</span><span style="" class=""><</span><span style="color:#703daa" class="">Int</span><span style="" class="">>.</span><span class="">arraySpacing</span><span style="" class=""> </span><span style="color:#008400" class="">// 8</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span class="">MemoryLayout</span><span style="" class=""><</span><span style="color:#703daa" class="">Int</span><span style="" class="">>.</span><span class="">alignment</span><span style="" class=""> </span><span style="color:#008400" class="">// 8</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">// Value</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="color:#bb2ca2" class="">let</span><span class=""> x: </span><span style="color:#703daa" class="">UInt8</span><span class=""> = </span><span style="color:#272ad8" class="">5</span></div></span><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span class="">MemoryLayout</span><span style="" class="">.</span><span style="color:#31595d" class="">of</span><span style="" class="">(</span><span class="">x</span><span style="" class="">).</span><span class="">size</span><span style="" class=""> </span><span style="color:#008400" class="">// 1</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span class="">MemoryLayout</span><span style="" class="">.</span><span style="color:#31595d" class="">of</span><span style="" class="">(</span><span style="color:#272ad8" class="">1</span><span style="" class="">).</span><span class="">size</span><span style="" class=""> </span><span style="color:#008400" class="">// 8</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span class="">MemoryLayout</span><span style="" class="">.</span><span style="color:#31595d" class="">of</span><span style="" class="">(</span><span style="color:#d12f1b" class="">"hello"</span><span style="" class="">).</span><span class="">arraySpacing</span><span style="" class=""> </span><span style="color:#008400" class="">// 24</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span class="">MemoryLayout</span><span style="" class="">.</span><span style="color:#31595d" class="">of</span><span style="" class="">(</span><span style="color:#272ad8" class="">29.2</span><span style="" class="">).</span><span class="">alignment</span><span style="" class=""> </span><span style="color:#008400" class="">// 8</span></div><span class=""><font color="#888888" class=""><div class=""><span style="color:#008400" class=""><br class=""></span></div><div class=""><span style="color:#008400" class=""><br class=""></span></div><div class=""><span style="color:#008400" class="">-- E</span></div></font></span></div><br class=""></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></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>