In staticly typed languages, a variable is a name which represents a piece of data of a specific Data Type. A data type's name should NOT be seperated. But this is not the case in C/C++. e.g.
int a[10];
An array of 10 integers is a specific data type. However, in C/C++, this specific data type's name is sperated into two parts by the variable name.
People certainly noticed this issue, and in successive languages like Java, this was improved.
int[] a;
In Go, it becomes even better by putting the [] first.
var a []int;
I say this is better because now you can read the code just from left to right by "define a variable named a whose type is array of integers.
No comments:
Post a Comment