[swift-evolution] Python Interop with Swift 4+

Brent Royal-Gordon brent at architechies.com
Tue Nov 21 21:17:28 CST 2017


> On Nov 20, 2017, at 10:50 AM, Slava Pestov via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
> What if you write ‘let fn = obj.method’?

Since Ruby doesn't distinguish between properties and methods, I would write the `subscript(dynamicProperty:)` getter to be equivalent to a zero-argument method call. This is a pragmatic tradeoff—property access is *way* more common than uncalled method access.

I assume that Swift would send `rubyObject.someMethod(_:_:)` through a method-related call, not a property-related one. Having a way to unambiguously specify a zero-argument method would allow the uncalled syntax to be used with Ruby methods which would otherwise be interpreted as properties.

(The setter on properties would handle the problem of Ruby's `=` methods. As for `?` and `!`, unless we extend the `identifier` syntax to allow non-identifier characters, I'd actually be tempted to bridge them with `is` and `unsafe` prefixes respectively. That might be a little too cute, though.)

-- 
Brent Royal-Gordon
Architechies

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


More information about the swift-evolution mailing list