Parameters and Arguments
This is (another) rant about misuse of technical terms.
Do you know what a parameter is?
How about an argument?
If you think they are the same, you aren't alone.
Consider this Kotlin code :
class Test { fun foo( i : int ) = i + 1 fun test() = foo(2) }
What is i?
What is 2?
IMHO, the answers are :
- i is a parameter of type Int.
- 2 is an argument to the foo function.
Generic Types in Java
Now for a trickier example, involving generics :
interface List<E:Any> { fun get( index : Int ) : E } val myList = listOf<String>()
If we use reflection, then we can ask about E using : Class<List>.getTypeParameters() So far so good. So what does it return? An array of TypeVariables. WTF? They are NOT variables, they can't change. They don't even have a value!
The class TypeVariable should obviously be renamed TypeParameter.
They got the other half slightly wrong too :
List<String> is a ParameterizedType. The rawType is List, and the actualTypeArguments is an array size 1 containing String.
But why did they qualify it with the word actual? I suspect it's because they didn't realise it is redundant.
The word argument MEANS it is the actual type, just as 2 is the actual value (aka argument) passed to foo.
Grr.
Main
PS. Here's a classic main entry point for a Java application.
static int main( String... args ) { ... }
main has one parameter of type Array of Strings, and it is called args (short for arguments).
That's weird (calling a parameter arguments). ;-)) I'm not saying the name is wrong, just really odd! (I can't think of a good name).