Comment by kragen
5 days ago
That looks like C. In C, declarations aren't statements: https://en.cppreference.com/w/c/language/statements.html
5 days ago
That looks like C. In C, declarations aren't statements: https://en.cppreference.com/w/c/language/statements.html
It's Hnlang, where declarations are statements. But perhaps the earlier comment was about C specifically? I admittedly missed it, if so.
In most programming languages, declarations aren't statements, because they don't have any effect at runtime. Maybe you can find some exceptions. Like in BASIC the DIM statement is sort of a declaration, but it does have a runtime effect; it changes the dimensions of an array. (Though some would say that in BASIC no statement is bright.)
> Maybe you can find some exceptions.
Including Ken Thompson's very own[1]. Fair enough that in the olden days there was a clearer distinction made, but even the man who (co-)created C changed his mind on that later because that is how the term has evolved. Now, in normal conversation, if you call `int x;` a statement, nobody is going to struggle to understand what you mean. Are you still living in the 1970s? If so, I admittedly missed that. My assumption was that this discussion is taking place in 2025 with the words of its time.
[1] https://go.dev/ref/spec#Statements
5 replies →