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

Erica Sadun erica at ericasadun.com
Tue Jun 21 14:14:22 CDT 2016


> On Jun 21, 2016, at 12:45 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Regarding the issue of existential metatypes with sizeof:
> 
> Pyry Jahkola points out one instance where the memorySize(type(of: …)) workaround won't work. When the value is an existential, it's illegal to ask for the size of its dynamic type: the result can't be retrieved at compile time:
> 
> let i = 123
> let c: CustomStringConvertible = i
> print(sizeof(c.dynamicType)) // error: cannot invoke 'sizeof' with an argument list of type '(CustomStringCo
> This could be enabled by having sizeof and friends formally take an Any.Type instead of <T> T.Type. (This might need some tweaking of the underlying builtins to be able to open existential metatypes, but it seems implementable.)

While I'm not a huge fan of Dave A's generic struct approach (for reasons detailed in the proposal), this could resolve one major issue I currently have with his alternative.

-- E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160621/7d30d040/attachment.html>


More information about the swift-evolution mailing list