[swift-evolution] [pitch] Eliminate the "T1 -> T2" syntax, require "(T1) -> T2"

Dave Abrahams dabrahams at apple.com
Mon Apr 18 17:24:08 CDT 2016


on Thu Apr 14 2016, Chris Lattner <swift-evolution at swift.org> wrote:

> On Apr 14, 2016, at 10:21 PM, John McCall <rjmccall at apple.com> wrote:
>> 
>>> On Apr 14, 2016, at 9:57 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> We currently accept function type syntax without parentheses, like:
>
>> To me, the unparenthesized style suggests that the input and output
>> are peers, which feels more natural for the sort of value-to-value
>> transform/predicate where this most commonly occurs.  Parenthesizing
>> the input feels fussier, which contributes to a sense that the
>> argument is just one component to producing the result.
>> The parentheses are grammatically unnecessary in most cases (by frequency of use in higher-use programming, not by feature count).  
>
> I agree with your point that many simple higher order programming
> examples (e.g. map, filter, etc) take a single argument.  That said, I
> don’t agree that this means that we should syntactically privilege
> this special case.  In many places in the Swift grammar we aim for
> consistency, even if it means a bit more punctuation in specific
> cases.

And, FWIW, the standard library higher-order functions are all declared
with parens around the argument list, because it is a more recognizable
form.

-- 
Dave



More information about the swift-evolution mailing list