[swift-users] Protocols, `mutating` and Value vs Reference Types.

Hooman Mehr hooman at mac.com
Fri Apr 29 15:31:21 CDT 2016


Hi,

I am designing APIs that need to support both reference (class/object) and value types. I am running into restrictions of `mutating` keyword in my protocols and this is causing a lot of duplication of code. In order to understand what I mean please take a look at this gist <http://gist.github.com/hooman/2b74d9756976a43330c1acfcfba699f3>. 

As you see, I have pairs of almost identical declarations: KeyValueStore vs KeyValueStoreObject, and AnyDictionaryStore vs AnyDictionaryStoreObject. This keeps rapidly growing as I am designing my APIs. Is there any sane way around this?

Thank you for your time,
Hooman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160429/5fe12adf/attachment.html>


More information about the swift-users mailing list