[swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

Magnus Ahltorp map at kth.se
Mon Dec 4 12:20:26 CST 2017


> 5 Dec. 2017 01:08 Benjamin G via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Unless DynamicLookup is used to circumvent every compiler warning or errors thrown at you by the language because your design is unsound. Something like "ho, yeah swift generics and protocols aren't really working fine together for your case, but just make everything DynamicLookupable and you'll be all set". Or "This JSON document has a really complex schema. Let's just not specify anything, and call the fields like this, you won't even feel any difference anyway".

We have heard these horror tales about everyone making "everything DynamicLookupable" and this being extremely bad, but can anyone actually produce a believable example? It's not like it's absurdly convenient to implement this, the ergonomics are at the call site, not the implementation. It sounds like you think that just conforming to DynamicMemberLookupProtocol and DynamicCallable will magically make everything in the code dynamic with no extra effort.

/Magnus



More information about the swift-evolution mailing list