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

BJ Homer bjhomer at gmail.com
Mon Nov 27 12:35:39 CST 2017


I like the proposal. Having a “magic” protocol isn’t ideal in some ways, but it seems like the best option for the moment, considering the other restrictions.

The name “DynamicMemberLookupProtocol” is a bit unwieldy, though. What about something like “SupportsDynamicMemberLookup“ or "SupportsDynamicMembers"? I know it doesn’t follow the usual protocol naming pattern, but for an empty “magic” protocol like this, it reads fairly well as a description of the capabilities of the type:

enum JSON: SupportsDynamicMemberLookup {
   // ...
}

Anyway, I like the proposal. The “Supports-“ prefix on the name may be a good idea, or may not. Either way, the “JSON” example in the proposal shows how this is useful for more than just bridging to dynamic languages, and is quite compelling to me.

-BJ


> On Nov 26, 2017, at 11:04 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I’d like to formally propose the inclusion of user-defined dynamic member lookup types.
> 
> Here is my latest draft of the proposal:
> https://gist.github.com/lattner/b016e1cf86c43732c8d82f90e5ae5438
> https://github.com/apple/swift-evolution/pull/768
> 
> An implementation of this design is available here:
> https://github.com/apple/swift/pull/13076
> 
> The implementation is straight-forward and (IMO) non-invasive in the compiler.
> 
> -Chris
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171127/257ea8e4/attachment.html>


More information about the swift-evolution mailing list