<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 <<a href="mailto:brent@architechies.com" class="">brent@architechies.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" class="">I don't disagree with the points you make. But one can argue that this is a good thing. It calls attention to code that requires extra attention and care. In some ways this is similar to 'UnsafeMutablePointer<T>' vs '*T'. 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<Int>.pointeeSize<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>UnsafePointer<Int>.pointeeAlignment<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>UnsafePointer<Int>.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: _sanityCheck(sizeofValue(self) >=</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<T>(_:T) -> 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: let bits = sizeofValue(initialUTF8) &* 8 &- 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: if utf8Count < 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: 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: 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: sendBytes(from: &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: sendBytes(from: &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: fread(&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: sendBytes(from: &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: let pointerSize = UInt8(sizeof(UnsafePointer<Void>.self))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">private/SwiftReflectionTest/SwiftReflectionTest.swift: let anyPointer = UnsafeMutablePointer<Any>(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: 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: 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: 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: 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: 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: 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: 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: 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: 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: sizeof(Optional<UnsafePointer<Void>>.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<T>(_:T.Type) -> Int {</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Builtin.swift: 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: 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: _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: 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: // 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: 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: _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: _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: == _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: _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: == _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: 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: _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: _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: _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: for _ in 0..<(2 * sizeof(UnsafePointer<Void>) - 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: // `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: 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: return 0xFF << numericCast((sizeof(Buffer.self) &- 1) &* 8)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public/core/Unicode.swift: 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: 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: 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: 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) <= 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: 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: 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: bytesPerIndex: sizeof(IndexType))</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div></div></body></html>