[swift-evolution] Python Interop with Swift 4+
david at alkaline-solutions.com
Tue Nov 21 00:48:06 CST 2017
> I think you’re missing the idea here: the idea isn’t to provide exactly syntax mapping of Ruby (or Python) into Swift, it is to expose the underlying semantic concepts in terms of Swift’s syntax. In the case of Python, there is a lot of direct overlap, but there is also some places where Swift and Python differs (e.g. Python slicing syntax vs Swift ranges). In my opinion, Swift syntax wins here, we shouldn’t try to ape a non-native syntax in Swift.
Just wanted to point out Ruby language rules. For swift, you’d probably want to have property-style accessors always return something akin to a function pointer.
>> More difficult would be the use of ‘=‘, ‘!’, and ‘?’ - all legal in Ruby method names as suffixes.
> Using those would require backquotes:
Ruby attributes syntax does wind up looking a bit ugly there. For `bar` on class `Foo` in ruby,
x.foo() # return value of attribute foo
x.`foo=`(5) # assign value of foo as 5
Not pretty, but it should work. All the approaches I’ve been thinking up to improve that wind up being pretty nonintuitive and fragile.
More information about the swift-evolution