on Thu Apr 28 2016, Xiaodi Wu <[email protected]> wrote:

> We all know and love sizeof(), but given that it's different from its C
> counterpart anyway, shouldn't these conform to Swift naming guidelines? In 
> other
> words, after SE-0006, shouldn't these names be as follows?
>
> ```
> size<T>(of: T.Type)
> size<T>(ofValue: T)
> stride<T>(of: T.Type)
> stride<T>(ofValue: T)
> align<T>(of: T.Type)
> align<T>(ofValue: T)
> ```
>
> There are obvious issues with two different things named `stride`, but IMO
> that's best addressed by renaming one of them; the real problem is that the 
> word
> stride is used in two different ways already. Thoughts?

These functions correspond to C and LLVM primitives and we consciously
kept those names because they are terms of art. I don't know that

  size(of: T.self)

is particularly descriptive usage, and if we were going to change them
so they didn't look like sizeof, strideof, alignof I'd want to make them
far more descriptive.  E.g.

  memoryFootprint(Int.self)

or

  bytesRequiredForStorage(Int.self)
  standardByteAlignment(Int.self)
  bytesBetweenArrayElements(Int.self)

etc.

-- 
Dave

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to