[swift-evolution] Make the first parameter in a function declaration follow the same rules as the others

ted van gaalen tedvgiosdev at gmail.com
Fri Mar 11 19:56:29 CST 2016


if parameter names are obligatory, one could
remove the commas completely in the function call:

     foo(a: v1  b: 123.45 c: qwertyuiop)

or alternatively with commas only:

     foo( a v1, b 123.45, c 12 * 3 + 2)


TedvG





> 
> Subject: Make the first parameter in a function declaration follow the same rules as the others
> 
> When I started using Swift (on the whole a pleasant journey)
> the most confusing thing to me was, and at times still is,  the parameter list,
> 
> 
> I would prefer:
> 
> -uniform for functions(…) AND init(…)
> -every parameter must be used with its name/label. Always, no exceptions.
> -no shortcuts. 
> -allow arbitrary parameter sequence.
> which is possible and very easy to implement when you always have to use names.
> -no trailing commas.
> 
> Because you always have to specify parameter names/labels
> it is easy to see (for the compiler) which parameters 
> are omitted.
> 
> Omitting a parameter for which no default value was 
> specified is still an error. 
> 
> The confusing # and _  are no longer necessary. 
> 
> 
> ‘inout’ and  external and local parameter names behavior remain as they are.
> 
> like so
> 
>     func foo(inout a: Type, b: Type = 12.34, c: Type)    // b may be omitted
> or
>     func foo(a alocal: Type, b blocal: Type = 12.34, c: Type= 3.14159)    // b and c may be omitted    
> 
> 
> Valid calls:
> 
>    foo(a: v1, b: v2, c: v3)     // in sequence
>    foo(c: v3, a: v1, b: v3)     // arbitrary parameter sequence is allowed.
> 
>    foo(c: v13)              // parms a and b are not present: default values wil be taken  
>                                   // or error if no default specified.
> 
> Allow for more than 1 variadic parameter, why is this currently limited to one variadic parameter only? 
> 
>    foo(a: Type, b:Type…, c: Type…,d: Type)
> 
> 
>   foo(v1,b: v2,c: v3) // this is an error: parameter name missing with first parameter.
> 
> 
> It would end the confusion.
> 
> 
> TedvG
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160312/a2741dd9/attachment.html>


More information about the swift-evolution mailing list