|
|
|
|
|
by int_19h
537 days ago
|
|
Having the identifier first makes it easier to parse unambiguously; the C syntax has been historically criticized for not being context-free because of stuff like "A * B" being impossible to parse correctly without knowing whether A is a type or not. While Java doesn't have the equivalent problem, Kotlin keeps its options open wrt future syntactic extensions for type names. Identifier-first can also be a lot more readable when gnarly (and thus lengthy) types are involved, since you don't have to scan the line to find it. It makes for neater-looking code with multiple declarations one after another, too. As far as commonality, both syntaxes are very common, and have been so historically as well (roughly speaking, C vs Pascal syntax families). It should also be noted that most new languages go for identifier-first, so if anything, it's more future-proof in this sense. |
|
And again, the point is that Kotlin brings along extra characters AND variation. What's next, `fnctn myFunction(x : Int)~ Int { /* code */ }`?
Why? Just to be quirky? To avoid some hypothetical lawsuit?