We removed "of" from the final version:

https://github.com/apple/swift-evolution/blob/master/proposals/0101-standardizing-sizeof-naming.md
 
<https://github.com/apple/swift-evolution/blob/master/proposals/0101-standardizing-sizeof-naming.md>

And moved it to "If for some reason, the core team decides that there's a 
compelling reason to include value calls, an implementation might look 
something like this" instead.

Dave expressed that this should be something that operates on types not values.

-- E


> On Jul 12, 2016, at 2:43 PM, Jordan Rose <jordan_r...@apple.com> wrote:
> 
> Sorry to only come across this now. The proposed implementation does not work.
> 
> public static func of(_ candidate : @autoclosure () -> T) -> 
> MemoryLayout<T>.Type {
>   return MemoryLayout.init(candidate).dynamicType
> }
> 
> let value: Any = 2 // dynamicType is Int
> let layout = MemoryLayout(value).dynamicType // inlined from above
> let arrayType = [value].dynamicType
> 
> ‘layout’ here is still 'MemoryLayout<Any>', not 'MemoryLayout<Int>', for the 
> same reason that ‘arrayType’ is ‘Array<Any>’ rather than ‘Array<Int>’.
> 
> If we want to support sizeofValue et al, we’d need to make these instance 
> properties rather than static properties, and may then want to give up on the 
> struct being generic.
> 
> Jordan

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to