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

Paul Cantrell cantrell at pobox.com
Sat Nov 18 10:12:54 CST 2017

> On Nov 18, 2017, at 1:44 AM, Jean-Daniel <mailing at xenonium.com> wrote:
>> In Ruby, `myObj.name()` is equivalent to `myObj.name`, and either works. In Swift, I don’t see that it’s possible to make both work with Chris’s proposal.
> IIUC, the goal is not to make swift look and behave the same as ruby or python, but to be able to use ruby or python object in a swift way (without indirect call and other nasty constructions). I don’t see requiring the .property syntax and prohibiting the .property() one as an issue. I would even say this is the thing to do, as it would make the swift code more understandable to Swift dev that are not used to Ruby.

It really wouldn’t. Zero-arg Ruby methods are a mixture of property-like things that would certainly not use parens in Swift, and function-like things that certainly would:

    // Idiomatic Swift:

    // Swift bridging to Ruby…

    // …if no-args methods •must• use parens:

    // …if no-args methods •can’t• use parens:

If the goal is to make Swift mostly look like Swift even when bridging to Ruby, then the bridge needs to support both access forms.

Cheers, P

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

More information about the swift-evolution mailing list