<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 21, 2016, at 12:45 PM, Joe Groff 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="">Regarding the issue of existential metatypes with sizeof:<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; 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="">Pyry Jahkola points out one instance where the <code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(0, 0, 0, 0.0392157); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">memorySize(type(of: …))</code> workaround won't work. When the value is an existential, it's illegal to ask for the size of its dynamic type: the result can't be retrieved at compile time:</p></div><div class=""><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; 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);"><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; 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;" class=""><span class="pl-k" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(167, 29, 93);">let</span><span style="font-size: 13.600000381469727px;" class=""> i </span><span class="pl-k" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(167, 29, 93);">=</span><span style="font-size: 13.600000381469727px;" class=""> </span><span class="pl-c1" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(0, 134, 179);">123</span></pre></div></div><div class=""><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; 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);"><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; 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;" class=""><span class="pl-k" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(167, 29, 93);">let</span><span style="font-size: 13.600000381469727px;" class=""> c: </span><span class="pl-c1" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(0, 134, 179);">CustomStringConvertible</span><span style="font-size: 13.600000381469727px;" class=""> </span><span class="pl-k" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(167, 29, 93);">=</span><span style="font-size: 13.600000381469727px;" class=""> i</span></pre></div></div><div class=""><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; 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);"><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; 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;" class=""><span class="pl-c1" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(0, 134, 179);">print</span><span style="font-size: 13.600000381469727px;" class="">(</span><span class="pl-c1" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(0, 134, 179);">sizeof</span><span style="font-size: 13.600000381469727px;" class="">(c</span><span class="pl-k" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(167, 29, 93);">dynamicType</span><span style="font-size: 13.600000381469727px;" class="">)) </span><span class="pl-c" style="font-size: 13.600000381469727px; box-sizing: border-box; color: rgb(150, 152, 150);">// error: cannot invoke 'sizeof' with an argument list of type '(CustomStringCo</span></pre></div></div></blockquote><div class=""><div class=""><b class="">This could be enabled by having sizeof and friends formally take an Any.Type instead of <T> T.Type.</b> (This might need some tweaking of the underlying builtins to be able to open existential metatypes, but it seems implementable.)</div></div></div></div></blockquote><br class=""></div><div>While I'm not a huge fan of Dave A's generic struct approach (for reasons detailed in the proposal), this could resolve one major issue I currently have with his alternative.</div><div><br class=""></div><div>-- E</div></body></html>