[swift-evolution] MemoryLayout for a value
Dave Abrahams
dabrahams at apple.com
Wed Aug 3 23:32:43 CDT 2016
on Wed Aug 03 2016, Xiaodi Wu <xiaodi.wu-AT-gmail.com> wrote:
> Agreed, but I do think "memory layout of type of my value, size" is a
> mouthful compared to "size of value".
It is, but it would avoid confusion.
> Moreover, something doesn't sit right with me that MemoryLayout<T> and
> MemoryLayout.of(T.self) would be one and the same thing.
As far as I'm concerned, that's a feature, not a bug. Unless you can
describe why it should be different, “it doesn't sit right” is not a
helpful argument.
> Could I suggest an alternative? It's conservative in that it mimics the
> relationships we had before the proposal was implemented and also maintains
> the simplicity of the caseless enum:
>
> ```
> extension MemoryLayout {
> static func size(ofValue _: T) -> Int { return MemoryLayout.size }
> // etc.
> }
> ```
That introduces even more potential for confusion than adding forwarding
vars to instances does. Now you're talking about “overloading” a static
property with a static method having the same base name.
--
-Dave
More information about the swift-evolution
mailing list