[swift-evolution] Trial balloon: conforming sizeof, sizeofValue, etc. to naming guidelines

Dave Abrahams dabrahams at apple.com
Mon May 2 15:59:08 CDT 2016


on Mon May 02 2016, Joe Groff <jgroff-AT-apple.com> wrote:

>> On May 2, 2016, at 1:10 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> 
>> on Mon May 02 2016, Joe Groff <swift-evolution at swift.org> wrote:
>> 
>
>>>> On May 2, 2016, at 9:46 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>>> 
>>>> 
>>>> on Sun May 01 2016, Xiaodi Wu <xiaodi.wu-AT-gmail.com> wrote:
>>>> 
>>> 
>>>>> It's a bad habit of mine, I guess, to err on the side of suggesting conservative
>>>>> changes on the assumption that it'll be maximally acceptable. If there's
>>>>> appetite for a more serious renaming, and as you say these are considered
>>>>> relatively rarely used, then it's a world of possibility!
>>>>> 
>>>>> We could do as Shawn suggested and follow precedent in some other languages by
>>>>> moving these functions out of the global scope. Perhaps these will meet with
>>>>> some satisfaction:
>>>>> 
>>>>> ```
>>>>> Memory.footprint(of:)
>>>>> Memory.alignment(of:)
>>>>> Memory.spacing(of:)
>>>>> ```
>>>> 
>>>> I'd rather have 
>>>> 
>>>> MemoryLayout<T>.size
>>>> MemoryLayout<T>.alignment
>>>> MemoryLayout<T>.spacing
>>> 
>>> This would be a legit use for 'extension Any'. IMO it'd be even better
>>> as just T.size, T.alignment, T.spacing.
>> 
>> I very much disagree.  I don't want to see Array(1..<100).size == 24.
>
> They would presumably be static members, so that wouldn't be valid. Array<Int>.size would be, though.

OK, but personally don't want it on Array either, especially not after
we get statically-sized arrays.

-- 
Dave


More information about the swift-evolution mailing list