<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:55 PM, Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com" class="">brent@architechies.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" class="">I don't disagree with the points you make. &nbsp;But one can argue that this is a good thing. &nbsp;It calls attention to code that requires extra attention and care. &nbsp;In some ways this is similar to 'UnsafeMutablePointer&lt;T&gt;' vs '*T'. &nbsp;Verbosity was a deliberate choice in that case.<br class=""></blockquote><br class="">You know...rather than introducing a new type like MemoryLayout, would it make sense to do this with static properties on UnsafePointer?<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>UnsafePointer&lt;Int&gt;.pointeeSize<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>UnsafePointer&lt;Int&gt;.pointeeAlignment<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>UnsafePointer&lt;Int&gt;.pointeeSpacing<br class=""><br class="">If you need this information, 90% of the time you're probably using UnsafePointer or one of its friends, right?<br class=""><br class="">-- <br class="">Brent Royal-Gordon<br class="">Architechies<br class=""><br class=""></div></div></blockquote><br class=""></div><div>Some quick greppage -- E</div><br class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/BridgeObjectiveC.swift:&nbsp; &nbsp; _sanityCheck(sizeofValue(self) &gt;=</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Builtin.swift:public func sizeofValue&lt;T&gt;(_:T) -&gt; Int {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Character.swift:&nbsp; &nbsp; let bits = sizeofValue(initialUTF8) &amp;* 8 &amp;- 1</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Unicode.swift:&nbsp; if utf8Count &lt; sizeofValue(result) {</span></div></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftPrivateLibcExtras/Subprocess.swift:&nbsp; &nbsp; let errnoSize = sizeof(errno.dynamicType)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftPrivateLibcExtras/SwiftPrivateLibcExtras.swift:&nbsp; &nbsp; return sizeof(UInt) * 8</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; sendBytes(from: &amp;address, count: sizeof(UInt.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; sendBytes(from: &amp;value, count: sizeof(T.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; fread(&amp;value, sizeof(UInt.self), 1, stdin)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; sendBytes(from: &amp;numInfos, count: sizeof(UInt.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; let pointerSize = UInt8(sizeof(UnsafePointer&lt;Void&gt;.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; let anyPointer = UnsafeMutablePointer&lt;Any&gt;(allocatingCapacity: sizeof(Any.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; anyPointer.deallocateCapacity(sizeof(Any.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; &nbsp; &nbsp; allocatingCapacity: sizeof(ThickFunction0.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; fn.deallocateCapacity(sizeof(ThickFunction0.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; &nbsp; &nbsp; allocatingCapacity: sizeof(ThickFunction1.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; fn.deallocateCapacity(sizeof(ThickFunction1.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; &nbsp; &nbsp; allocatingCapacity: sizeof(ThickFunction2.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; fn.deallocateCapacity(sizeof(ThickFunction2.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; &nbsp; &nbsp; allocatingCapacity: sizeof(ThickFunction3.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift:&nbsp; fn.deallocateCapacity(sizeof(ThickFunction3.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/BridgeObjectiveC.swift: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sizeof(Optional&lt;UnsafePointer&lt;Void&gt;&gt;.self) * count)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/<a href="Builtin.swift:///" class="">Builtin.swift:///</a> In particular, `sizeof(X.self)`, when `X` is a class type, is the</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Builtin.swift:public func sizeof&lt;T&gt;(_:T.Type) -&gt; Int {</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Builtin.swift:&nbsp; return Int(Builtin.sizeof(T.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/<a href="Builtin.swift:///" class="">Builtin.swift:///</a> In particular, `sizeof(a)`, when `a` is a class instance, is the</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Builtin.swift:&nbsp; return sizeof(T.self)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Builtin.swift:&nbsp; _precondition(sizeof(T.self) == sizeof(U.self),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Builtin.swift:&nbsp; &nbsp; sizeof(_HeapObject.self),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Character.swift:&nbsp; &nbsp; // Notice that the result of sizeof() is a small non-zero number and can't</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/HeapBuffer.swift:&nbsp; &nbsp; &nbsp; sizeof(_HeapObject.self),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/HeapBuffer.swift:&nbsp; &nbsp; &nbsp; _valueOffset() + sizeof(Value.self),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/ManagedBuffer.swift:&nbsp; &nbsp; &nbsp; _class_getInstancePositiveExtentSize(bufferClass) == sizeof(_HeapObject.self)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/ManagedBuffer.swift:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; == _valueOffset + sizeof(Value.self)),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/ManagedBuffer.swift:&nbsp; &nbsp; &nbsp; _class_getInstancePositiveExtentSize(bufferClass) == sizeof(_HeapObject.self)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/ManagedBuffer.swift:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; == _valueOffset + sizeof(Value.self)),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/ManagedBuffer.swift:&nbsp; &nbsp; &nbsp; sizeof(_HeapObject.self),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/ManagedBuffer.swift:&nbsp; &nbsp; &nbsp; _valueOffset + sizeof(Value.self),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Runtime.swift.gyb:&nbsp; _sanityCheck(sizeof(_Buffer32.self) == 32)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Runtime.swift.gyb:&nbsp; _sanityCheck(sizeof(_Buffer72.self) == 72)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Runtime.swift.gyb:&nbsp; for _ in 0..&lt;(2 * sizeof(UnsafePointer&lt;Void&gt;) - result.utf16.count) {</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Sequence.swift:&nbsp; &nbsp; // `n` * sizeof(Iterator.Element) of memory, because slices keep the entire</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/StringUTF8.swift:&nbsp; &nbsp; &nbsp; let utf16Count = Swift.min(sizeof(_UTF8Chunk.self), count - i)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/StringUTF8.swift:&nbsp; &nbsp; &nbsp; &nbsp; return 0xFF &lt;&lt; numericCast((sizeof(Buffer.self) &amp;- 1) &amp;* 8)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Unicode.swift:&nbsp; let utf8Max = sizeof(_UTF8Chunk.self)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/VarArgs.swift:&nbsp; &nbsp; count: (sizeof(T.self) + sizeof(Int.self) - 1) / sizeof(Int.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/VarArgs.swift:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; size: UInt(sizeof(T.self)))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/VarArgs.swift:&nbsp; &nbsp; &nbsp; let alignmentInWords = arg._cVarArgAlignment / sizeof(Int)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/runtime/HeapObject.cpp:extern "C" intptr_t swift_bufferHeaderSize() { return sizeof(HeapObject); }</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/runtime/Once.cpp:static_assert(sizeof(swift_once_t) &lt;= sizeof(void*),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/SDK/CoreAudio/CoreAudio.swift:&nbsp; &nbsp; return sizeof(AudioBufferList) +</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/SDK/SceneKit/SceneKit.swift:&nbsp; &nbsp; &nbsp; data: NSData(bytes: indices, length: indexCount * sizeof(IndexType)),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/SDK/SceneKit/SceneKit.swift:&nbsp; &nbsp; &nbsp; bytesPerIndex: sizeof(IndexType))</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div></div></body></html>