[swift-evolution] [Pitch] Renaming sizeof, sizeofValue, strideof, strideofValue

Matthew Johnson matthew at anandabits.com
Thu Jun 2 11:11:47 CDT 2016


> On Jun 2, 2016, at 11:04 AM, Pyry Jahkola <pyry.jahkola at iki.fi> wrote:
> 
>> Matthew Johnson wrote:
>> 
>> Going with MemoryLayout *does not* mean we would have to give up the value functions if we don’t want to:
>> 
>> struct MemoryLayout<T> {
>>     init(t: T) { /* throw away the value */ }
>>     // …
>> }
>> 
>> let sizeOfValue = MemoryLayout(42).size
> 
> You could also use @autoclosure here to avoid evaluating whatever expression there is:
> 
> struct MemoryLayout<T> {
>     init(_: @autoclosure () -> T) {}
>     // ...
> }

Brilliant!  Why didn’t I think of that? :-)

> 
> — Pyry
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160602/5176840b/attachment.html>


More information about the swift-evolution mailing list