Upon accepting SE-0098, the core team renamed the proposed stdlib function from dynamicType() to type(of:). They write, "The core team recognizes that this means that we should probably resyntax the existing sizeof/strideof functions, but that should be a follow-on discussion."
Follow on discussion started. Have at it.
See: http://thread.gmane.org/gmane.comp.lang.swift.evolution/15830
To summarize the previous discussion:
1. Per Joe Groff, although sizeof() and friends are treated as terms-of-art, these names were lifted straight from C and do not correspond to anything named "sizeof" in LLVM.
2. There are issues with using a name such as stride(of:), because stride(...) already means something else in the stdlib; moreover, size(of:) isn't the best name for something that doesn't do what its C namesake does; therefore, larger changes to the naming were suggested.
2. Dave A. and others expressed the opinion that these should probably not be global functions; his preference was for:
MemoryLayout<T>.size // currently sizeof() MemoryLayout<T>.spacing // currently strideof() MemoryLayout<T>.alignment // currently alignof()
Thanks for the summary. I missed the original thread.
I think I like this approach despite its verbosity. Will give it a little bit more thought...
ยทยทยท
Sent from my iPad
On Jun 2, 2016, at 12:05 AM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org> wrote:
On Wed, Jun 1, 2016 at 11:55 PM, Xiaodi Wu <xiaodi.wu@gmail.com> wrote:
On Wed, Jun 1, 2016 at 11:28 PM, Erica Sadun via swift-evolution <swift-evolution@swift.org> wrote:
3. Dave A. proposed that sizeofValue(), strideofValue(), and alignofValue() are better off removed altogether. I don't know if people are going to be happy about this idea.
* * *
If we take inspiration from type(of:), then it's actually sizeofValue(), etc., that should be renamed size(of:), etc. Also, a fun tidbit is that what's currently called sizeof(), etc.--the ones that take types rather than values--are actually not very good candidates for having parameter labels, because it's OK to write `sizeof(Int)`, but one must currently write `size(of: Int.self)` when the function has a label.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution