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

Chris Lattner clattner at nondot.org
Thu Dec 7 13:12:34 CST 2017


> On Dec 7, 2017, at 9:20 AM, BJ Homer via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> So while it’s theoretically possible to do this, I don’t think it’s a concern in practice. The incentives are already in place to encourage doing the “right” thing in this case, even with the possibility of dynamic member lookup.
>> 
>> -BJ
>> 
>> Hey, thanks for answering that part of the concern. i also came to this point, but wondered if the dictionary couldn't be made of type [String: DynamicValue] where DynamicValue would have some way to be  automatically casted to string, int, etc, by reusing the same mechanism that the proposal would use to convert PyVal to regular swift types. I stopped at this point.
>> 
> 
> 
> As far as I am aware, the proposal provides no mechanism for automatically converting back from PyVal to regular Swift types. You would have to do something explicit like myPythonValue.intValue, or String(myPythonValue).

That is correct, these proposals have nothing to do with conversions like that.

If you look at the Python prototype I sent out, the primitive types like Int/String/etc have failable conversion from PyVal (they return an optional).

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171207/4d34e7a2/attachment.html>


More information about the swift-evolution mailing list