<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Chris,</div><div><br></div><div>There are only a few examples in the proposal that demonstrate using dynamic member lookup.</div><div><br></div><div>I suppose that some examples will look like this:</div><div><br></div><div>let foo: PyRef = ...</div><div></div><blockquote type="cite"><font color="#000000"></font></blockquote><div>foo.bar // translates into foo[dynamic: “bar”]</div><div>foo.bar.baz // translates into foo[dynamic: “bar”][dynamic: “baz”]</div><div><br></div><div>and if we have:</div><div><br></div><div>extension PyRef {</div><div> var one: Int {</div><div> return 1</div><div> }</div><div>}</div><div><br></div><div>foo.bar.one // returns 1, because it translates into foo[dynamic: “bar”].one</div><div><br></div><div>This to me is hinting that dynamic member lookup will only be applied to one property at a time. In order for it to work on multiple levels, the type being returned by the subscript operation must still conform to DynamicMemberLookup. Is this how you envisioned it to work?</div><div><br></div><div>Cheers,</div><div>Andrew</div><div><br></div><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">Hi All,<br><br>As a peer to the DynamicCallable proposal (<a href="https://gist.github.com/lattner/a6257f425f55fe39fd6ac7a2354d693d">https://gist.github.com/lattner/a6257f425f55fe39fd6ac7a2354d693d</a> <<a href="https://gist.github.com/lattner/a6257f425f55fe39fd6ac7a2354d693d">https://gist.github.com/lattner/a6257f425f55fe39fd6ac7a2354d693d</a>>), I’d like to get your feedback on making member lookup dynamically extensible. My primary motivation is to improve interoperability with dynamic languages like Python, Perl, Ruby, Javascript, etc, but there are other use cases (e.g. when working with untyped JSON).<br><br>In addition to being a high impact on expressivity of Swift, I believe an implementation can be done in a way with changes that are localized, and thus not have significant impact on the maintainability of the compiler as a whole. Once the pitch phase of this proposal helps refine the details, I’ll be happy to prepare an implementation for consideration.<br><br>In case it is useful, I’m working on cleaning up my current prototype Python bindings. I’ll share them in the next day or two in case they are useful to provide context. It is amazingly simple: less than 500 lines of Swift code (plus some small additional C header glue to work around clang importer limitations) enables impressive interoperability. The only problems are the verbosity addressed by this proposal and the peer DynamicCallable proposal.<br><br><br>Here is the canonical proposal URL:<br><a href="https://gist.github.com/lattner/b016e1cf86c43732c8d82f90e5ae5438">https://gist.github.com/lattner/b016e1cf86c43732c8d82f90e5ae5438</a> <<a href="https://gist.github.com/lattner/b016e1cf86c43732c8d82f90e5ae5438">https://gist.github.com/lattner/b016e1cf86c43732c8d82f90e5ae5438</a>><br><br>A snapshot of the proposal is included below in case it is useful. Thanks in advance for help improving the proposal!<br><br>-Chris</span></font></blockquote></body></html>