[swift-evolution] Move placement of 'throws' statement
Chris Lattner
clattner at apple.com
Wed Dec 28 22:14:35 CST 2016
> 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, 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?
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161228/49f0acc1/attachment.html>
More information about the swift-evolution
mailing list