> On Jun 21, 2016, at 1:23 PM, Dave Abrahams <dabrah...@apple.com> wrote: > > > > > on Tue Jun 21 2016, Joe Groff > <swift-evolution-m3fhrko0vlzytjvyw6y...@public.gmane.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: >> >> // Swift 2.2, 64-bit >> let i = 123 >> print(sizeofValue(i)) //=> 8 >> let c: CustomStringConvertible = i >> print(sizeofValue(c)) //=> 40 >> 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.) > > Would it be as fully specializable down to a compile-time constant? Seems like it ought to be. sizeof() is just a transparent wrapper around Builtin.sizeof IIRC, and we can control the codegen of the builtin. -Joe _______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution
Re: [swift-evolution] [Review] SE-0101: Rename sizeof and related functions to comply with API Guidelines
Joe Groff via swift-evolution Tue, 21 Jun 2016 15:27:18 -0700
- Re: [swift-evolution] [Re... Dave Abrahams via swift-evolution
- Re: [swift-evolution]... Erica Sadun via swift-evolution
- Re: [swift-evolut... Dave Abrahams via swift-evolution
- Re: [swift-e... Erica Sadun via swift-evolution
- Re: [swi... Dave Abrahams via swift-evolution
- Re: [swi... David Waite via swift-evolution
- Re: [swi... Erica Sadun via swift-evolution
- Re: [swi... Dave Abrahams via swift-evolution
- Re: [swi... Patrick Smith via swift-evolution
- Re: [swift-evolution] [Review... Dave Abrahams via swift-evolution
- Re: [swift-evolution] [Re... Joe Groff via swift-evolution
- Re: [swift-evolution] [swift-evolu... Scott James Remnant via swift-evolution
- Re: [swift-evolution] [Review] SE-... Brent Royal-Gordon via swift-evolution
- Re: [swift-evolution] [Review] SE-... Matthew Johnson via swift-evolution