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

Chris Lattner clattner at nondot.org
Fri Dec 1 00:15:38 CST 2017


On Nov 30, 2017, at 3:46 AM, Matt Diephouse <matt+swift-evolution at diephouse.com> wrote:
> The examples in the proposal are very shallow, highlighting single lookups. But what are the types of the returned values?

The Python example is recursive: PyVal is returned and is the source of dynamism, so it chains arbitrarily.

I encourage you to check out the Playground I sent out on Nov 19 to swift-evolution which shows how all this works in more detail.

> I think the proposal should include a more complete example that demonstrates how meaningful interop code could be written.

The proposal is independent of any specific bridge, I covered one possible way that Python could be bridged in that playground.  That said, the actual design of a Python bridge will itself be a follow-on proposal.

> 2. The JavaScript example will be popular, but isn’t actually that useful
> 
> Swift already has `Codable`, which provides more automatic and more type-safe (in that it encourages all-or-nothing decoding) JSON decoding. 

This only helps you if you control the JSON format or if it has a principled structure that maps nicely to Swift.  If you’re working with some existing service which is poorly structured and inconsistent, then it is very useful.

That said, the JSON example is simply an example to illustrate the ideas in the proposal, it is not part of the proposal itself.

-Chris


More information about the swift-evolution mailing list