This is often called function overloading in programming language theory. In Swift, among other languages, a function is uniquely identified by its names and arguments (i.e., types and argument labels). This function identification is sometimes called function signature. Note that the function return type isn't part of said signature.
For instance, all Swift functions below are completely different from each other:
func run()
func run(x: Int)
func run(y: Int)
func run(_ x: Int)
func run(_ y: Float)
func run(x: Int, y: Int)
As such, the run
function is overloaded with many variants, hence the feature name.
But these two are the same and will trigger a compiler error:
func run(_ x: Int)
func run(_ y: Int)
both functions share the same signature since: no arg label is provided for their only arg (the _
does this trick) and the sole arg has the same type (Int
).
This capability is also available in C++, C#, and Java. But in these languages, the arg name is not part of the function signature, only the arg types are. As you might guess, this is recurring source of confusion for those coming to Swift.
Conversely, the C and Python languages you mentioned, don't support overloading, which might explain your minor confusion :)
Finally, the classic Ada programming language supports a function overloading mechanism very similar to Swift.