Hi everyone, this is my first post, hopefully I get the formatting and 
everything right...
> why not just require a leading dot, like an enum, rather than a colon?
> less syntax to learn, and it still eliminates the extra type.
I think this could lead to ambiguity if the trailing argument label was also an 
enum case, and there was a function signature whose last argument type was that 
enum. E.g.,
enum E {
        case trailing
}
func foo(_ i: Int, trailing: E) {}
func foo(_ i: Int, trailing) {}

Now, which version of foo gets called by foo(1, .trailing)? It's a contrived 
example but demonstrates a real problem.
Since the dollar sign is so rarely used — correct me if I'm wrong, but its only 
current use is for positional closure arguments — I propose we use it for 
trailing arguments. The fact that it seems out of place in a function context 
makes its intention clear — unlike, say, a colon which definitely "belongs" 
within a function's parentheses, or a period which can go just about anywhere.
The syntax I propose would be the following:
// Define
func foo(_ i: Int, $trailing) {}
// Call
foo(1, $trailing)

It's not exactly pretty, but it's certainly unambiguous and makes the intention 
clear.

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to