[swift-evolution] [Pitch] Renaming sizeof, sizeofValue, strideof, strideofValue
Erica Sadun
erica at ericasadun.com
Thu Jun 2 16:59:43 CDT 2016
> On Jun 2, 2016, at 3:55 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>
>> 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.
>
> You know...rather than introducing a new type like MemoryLayout, would it make sense to do this with static properties on UnsafePointer?
>
> UnsafePointer<Int>.pointeeSize
> UnsafePointer<Int>.pointeeAlignment
> UnsafePointer<Int>.pointeeSpacing
>
> If you need this information, 90% of the time you're probably using UnsafePointer or one of its friends, right?
>
> --
> Brent Royal-Gordon
> Architechies
>
Some quick greppage -- E
public/core/BridgeObjectiveC.swift: _sanityCheck(sizeofValue(self) >=
public/core/Builtin.swift:public func sizeofValue<T>(_:T) -> Int {
public/core/Character.swift: let bits = sizeofValue(initialUTF8) &* 8 &- 1
public/core/Unicode.swift: if utf8Count < sizeofValue(result) {
private/SwiftPrivateLibcExtras/Subprocess.swift: let errnoSize = sizeof(errno.dynamicType)
private/SwiftPrivateLibcExtras/SwiftPrivateLibcExtras.swift: return sizeof(UInt) * 8
private/SwiftReflectionTest/SwiftReflectionTest.swift: sendBytes(from: &address, count: sizeof(UInt.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: sendBytes(from: &value, count: sizeof(T.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: fread(&value, sizeof(UInt.self), 1, stdin)
private/SwiftReflectionTest/SwiftReflectionTest.swift: sendBytes(from: &numInfos, count: sizeof(UInt.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: let pointerSize = UInt8(sizeof(UnsafePointer<Void>.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: let anyPointer = UnsafeMutablePointer<Any>(allocatingCapacity: sizeof(Any.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: anyPointer.deallocateCapacity(sizeof(Any.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: allocatingCapacity: sizeof(ThickFunction0.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: fn.deallocateCapacity(sizeof(ThickFunction0.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: allocatingCapacity: sizeof(ThickFunction1.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: fn.deallocateCapacity(sizeof(ThickFunction1.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: allocatingCapacity: sizeof(ThickFunction2.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: fn.deallocateCapacity(sizeof(ThickFunction2.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: allocatingCapacity: sizeof(ThickFunction3.self))
private/SwiftReflectionTest/SwiftReflectionTest.swift: fn.deallocateCapacity(sizeof(ThickFunction3.self))
public/core/BridgeObjectiveC.swift: sizeof(Optional<UnsafePointer<Void>>.self) * count)
public/core/Builtin.swift:/// In particular, `sizeof(X.self)`, when `X` is a class type, is the
public/core/Builtin.swift:public func sizeof<T>(_:T.Type) -> Int {
public/core/Builtin.swift: return Int(Builtin.sizeof(T.self))
public/core/Builtin.swift:/// In particular, `sizeof(a)`, when `a` is a class instance, is the
public/core/Builtin.swift: return sizeof(T.self)
public/core/Builtin.swift: _precondition(sizeof(T.self) == sizeof(U.self),
public/core/Builtin.swift: sizeof(_HeapObject.self),
public/core/Character.swift: // Notice that the result of sizeof() is a small non-zero number and can't
public/core/HeapBuffer.swift: sizeof(_HeapObject.self),
public/core/HeapBuffer.swift: _valueOffset() + sizeof(Value.self),
public/core/ManagedBuffer.swift: _class_getInstancePositiveExtentSize(bufferClass) == sizeof(_HeapObject.self)
public/core/ManagedBuffer.swift: == _valueOffset + sizeof(Value.self)),
public/core/ManagedBuffer.swift: _class_getInstancePositiveExtentSize(bufferClass) == sizeof(_HeapObject.self)
public/core/ManagedBuffer.swift: == _valueOffset + sizeof(Value.self)),
public/core/ManagedBuffer.swift: sizeof(_HeapObject.self),
public/core/ManagedBuffer.swift: _valueOffset + sizeof(Value.self),
public/core/Runtime.swift.gyb: _sanityCheck(sizeof(_Buffer32.self) == 32)
public/core/Runtime.swift.gyb: _sanityCheck(sizeof(_Buffer72.self) == 72)
public/core/Runtime.swift.gyb: for _ in 0..<(2 * sizeof(UnsafePointer<Void>) - result.utf16.count) {
public/core/Sequence.swift: // `n` * sizeof(Iterator.Element) of memory, because slices keep the entire
public/core/StringUTF8.swift: let utf16Count = Swift.min(sizeof(_UTF8Chunk.self), count - i)
public/core/StringUTF8.swift: return 0xFF << numericCast((sizeof(Buffer.self) &- 1) &* 8)
public/core/Unicode.swift: let utf8Max = sizeof(_UTF8Chunk.self)
public/core/VarArgs.swift: count: (sizeof(T.self) + sizeof(Int.self) - 1) / sizeof(Int.self))
public/core/VarArgs.swift: size: UInt(sizeof(T.self)))
public/core/VarArgs.swift: let alignmentInWords = arg._cVarArgAlignment / sizeof(Int)
public/runtime/HeapObject.cpp:extern "C" intptr_t swift_bufferHeaderSize() { return sizeof(HeapObject); }
public/runtime/Once.cpp:static_assert(sizeof(swift_once_t) <= sizeof(void*),
public/SDK/CoreAudio/CoreAudio.swift: return sizeof(AudioBufferList) +
public/SDK/SceneKit/SceneKit.swift: data: NSData(bytes: indices, length: indexCount * sizeof(IndexType)),
public/SDK/SceneKit/SceneKit.swift: bytesPerIndex: sizeof(IndexType))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160602/4b6c6013/attachment.html>
More information about the swift-evolution
mailing list