2016-08-04 10:31 GMT+03:00 Xiaodi Wu via swift-evolution < [email protected]>:
> On Thu, Aug 4, 2016 at 2:29 AM, Karl <[email protected]> wrote: > >> It’s confusing because metatypes in Swift are pretty confusing in >> general: Int.self returns Int.Type which is not the same as `type(of: <some >> Int>)` (that would be Int). >> >> If a novice wants to jump in, they’ll have to know that MemoryLayout(of: >> Int.self) would return a MemoryLayout<Int.Type>. >> > > Yes, here, I agree Dave is absolutely right. You and Dave have convinced > me that neither `MemoryLayout(of: x)` nor `MemoryLayout.of(x)`, where x is > an instance, would be appropriate. > Two weeks ago Adrian and I suggested adding dynamic 'size', 'stride', 'alignment' to Mirror, which definition would look like: public struct Mirror { internal metatype_: Any.Type public init<T>(_: T.Type) public var size: Int { get } public var stride: Int { get } public var align: Int { get } // ... } There are some problems with it right now, but I do believe that reflection API is where dynamic `size`, `stride`, `alignment` belong.
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
