Timeline for Why does the type go after the variable name in modern programming languages?
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 7, 2024 at 0:12 | comment | added | zeel |
"But this doesn't actually make much sense: you basically have to explicitly write a type that says that you don't write a type." This seems like a weak argument. In the other languages, you are required to write var regardless of including the type. Typically the" I don't want to bother" situation is complex types anyway, where auto or var are equally preferable. But when you do include a type in thsse languages, you still have to include var and a colon and make the whole thing read awkwardly while you do it.
|
|
| Apr 22, 2022 at 12:27 | comment | added | matrixel | In C the declaration syntax does match the expression syntax. The C syntax "int* a, b" is not ambiguous if you associate the asterisk with the identifier ("int *a, b") , as the compiler does. Granted C++ adopted a different convention, which IMO is unfortunate because it is confusing. | |
| Aug 13, 2019 at 9:44 | comment | added | Sopel |
"But this doesn't actually make much sense: you basically have to explicitly write a type that says that you don't write a type." Well, the type-on-the-right version is exactly the same in your example... Also I disagree that it doesn't make sense. It makes exactly as much sense as func in Go.
|
|
| Jul 21, 2019 at 6:22 | comment | added | Det |
"Your premise is flawed on two fronts" All of those are newer than C# or D.
|
|
| Mar 6, 2018 at 13:21 | comment | added | Pierre Henry | While I fond it equally readable once you get used to it and the optional type argument is strong, I would like to point out that the IDE is not able to automatically propose variable names based on the type. I miss that when I write TypeScript. | |
| Apr 20, 2016 at 13:50 | comment | added | 8bittree |
Seems the ability to leave out the type and still have simple parsing is granted by the addition of var, auto, let, or the like, not by which side of the variable the type declaration is on. var Int x = 5 or even Int var x = 5 could both be shortened to var x = 5.
|
|
| Apr 20, 2016 at 1:19 | history | answered | Jörg W Mittag | CC BY-SA 3.0 |