[swift-evolution] [Review] SE-0101: Rename sizeof and related functions to comply with API Guidelines

Brandon Knope bknope at me.com
Tue Jun 28 16:18:28 CDT 2016


Isn't dynamicType possibly changing soon to a method?

This could look much different

Brandon 

> On Jun 28, 2016, at 4:53 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
> 
> On Jun 28, 2016, at 12:11 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>>> I think it would.  It would *really* help if someone would prepare a
>>>> patch that uses both APIs so we could see how the resulting code looks
>>>> in practice. :-)
>>>> 
>>>> -- 
>>>> Dave
>>> 
>>> Here you go:
>>> https://gist.github.com/erica/57a64163870486468180b8bab8a6294e
>>> <https://gist.github.com/erica/57a64163870486468180b8bab8a6294e>
>> 
>> Thanks for the proposal, Erica.  It contains some errors that I pointed
>> out in a comment on the Gist.  Care to fix those?
>> 
> 
> public struct MemoryLayout<T> {
>     public static var size: Int { return sizeof(T) }
>     public static var interval: Int { return strideof(T) }
>     public static var alignment: Int { return alignof(T) }
>     
>     init(_ : @autoclosure () -> T) {}
> }
> 
> print(MemoryLayout<Int>.size) // 8
> print(MemoryLayout<Int>.interval) // 8
> print(MemoryLayout<Int>.alignment) // 8
> 
> let x = 8
> 
> print(MemoryLayout(x).dynamicType.size) // 8
> print(MemoryLayout(x).dynamicType.interval) // 8
> print(MemoryLayout(x).dynamicType.alignment) // 8
> 
> -- E
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160628/42206fa7/attachment.html>


More information about the swift-evolution mailing list