[swift-evolution] Move placement of 'throws' statement
Dave Abrahams
dabrahams at apple.com
Wed Dec 28 23:33:34 CST 2016
on Wed Dec 28 2016, Chris Lattner <clattner-AT-apple.com> wrote:
>> On Dec 28, 2016, at 9:52 AM, Dave Abrahams <dabrahams at apple.com> wrote:
>>
>>> it would be ambiguous to move the ‘throws’ keyword to the end of the
>>> function type, because you'd get:
>>>
>
>>> let x : (_ a : Int) -> (_ b: Float) -> Double throws throws
>>
>> I see.
>>
>> We *could* say that the "throws" keyword comes after the return type
>> unless it's a function type, in which case it comes after the return
>> type's parameter list
>>
>> let x : (_ a : Int) -> (_ b: Float) throws -> Double throws
>>
>> I admit this is a horrible rule from a language designer's point of view
>> but there's a chance it could end up being better for users.
>
> Indeed this is horrid for an ivory tower language designer, but the
> pragmatic among them often have to make concessions to the real world.
> That said, I think this would be worse for typical swift programmers
> as well: it introduces multiple ways to do things,
Do you mean it introduces multiple ways to do the *same* thing? I
didn't think I was introducing any of those. If you think I was, you
probably misunderstood my suggestion (or I did!), FWIW.
> which work inconsistently and surprisingly in some cases.
>
> Here is a different way of looking at this: The predictable case is
> the one we already have now (and we wouldn’t take it away). Is your
> beef with the current syntax so great that you think it is worth
> adding complexity to the language to privilege some special cases?
Not really, no.
--
-Dave
More information about the swift-evolution
mailing list