[swift-evolution] [Pitch] Hashable types on RawRepresentable enums or a protocol for custom enum-like types

Adrian Zubarev adrian.zubarev at devandartist.com
Tue Oct 4 13:19:13 CDT 2016


Okay thanks, I’ll keep that in mind.



-- 
Adrian Zubarev
Sent with Airmail

Am 4. Oktober 2016 um 20:16:12, Joe Groff (jgroff at apple.com) schrieb:


On Oct 4, 2016, at 11:07 AM, Adrian Zubarev <adrian.zubarev at devandartist.com> wrote:

Doesn’t this imply more performance cost? Don’t get me wrong but the value here is not fixed and computed all over again which might waste resources if the calculation is complicated. Sure we could build some workarounds here and there, but the codebase won’t get any prettier after that.

I doubt it. Formally, integer and string literals are also constructor calls, but they're inlined and constant-folded away in most cases. A struct construction is also likely to be optimized. The code pattern I presented is exactly what the compiler automatically generates when you use the sugar syntax.

-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161004/9f72687e/attachment.html>


More information about the swift-evolution mailing list