[swift-evolution] [Pitch] Introduce user-defined dynamically "callable" types

Chris Lattner sabre at nondot.org
Fri Nov 10 19:44:54 CST 2017


On Nov 10, 2017, at 11:42 AM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>>> On Nov 10, 2017, at 10:57 AM, Alejandro Martinez via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> This seems a really interesting solution Chris.
>>> Similar to what Joe mentions I think this would also be appreciated by
>>> the community to make even nicer DSLs in Swift, which may or may not
>>> be a good side effect of the proposal.
>>> Also, I'm just wondering, how much complication adds this to the
>>> compiler itself that would have to be maintained in the future?
>> 
>> This is a very localized and simple change to the compiler.  Assuming the pitch process goes well, I will provide an implementation.
> 
> I don't think it's that localized. It's going to make call resolution massively more complicated.  Through great pain and community anguish, we pushed ourselves to a model where argument labels are parts of the declaration name, not part of the call argument, and this would throw us straight back into the kinds of complications of dealing with overloaded name- and type-dependent behavior we're trying to get away from in the language.

I’m pretty sure it doesn’t, but good news: since Swift requires an implementation before the proposal can be officially reviewed, you will be able to look at the actual patch to make this decision.

> Swift is a dynamic language too, and tuples have enough metadata in them that you could get almost everything you want with an infix operator.

This is really gross.  The goal here is to make Python feel natural.  If you oppose this proposal then we’ll have to find some other way to provide an elegant experience:

> x∫(0, "foo", bar: "bas”)

This is not going to be acceptable to users.

-Chris



More information about the swift-evolution mailing list