IDE:Visual Studio X/Fire Version:10.0.0.2399 (develop) Target (If relevant): OSX Description:
Using _ as an external name, but providing no internal name should be allowed.
This provides internal documentation that one does not use that parameter, and
in protocols, the internal name is merely a suggestion for the implementor.
Expected Behavior:
Compiles, one cannot use the parameter (non-protocol). Actual Behavior:
“E: identifier expected, got wildcard [<file> (<line>)]” Steps:
One related case: externally named, internally unnamed parameter.
func foo<T>(from _: T.Type) { // colon expected
// Use T (not the value of T.Type)
}
Why would one use this?
Because the (standard) Swift compiler forbids explicitly specializing generic functions, generic functions must explicitly take or return a value which can select the generic’s value. In absence of any other alternative T.Type may be used.
However, such parameters may not need to be named internally, but may be named externally.
Edit: also the parser does not like explicitly removing the external name of the first parameter: