Comment by lmm

5 days ago

> Given a declaration "statement" such as:

> int x;

> What is the expected action?

In a language that requires you to declare variables before you use them, it clearly does something - you couldn't do "x = 5;" before, and now you can. If you're trying to understand the program operationally (and if you're not then why are you thinking about statements?) it means something like "create a variable called x", even if the implementation of that is a no-op at the machine code level.

> I believe, in the age of type systems being all the rage, one would simply see that as a type constraint, not as a command to act upon.

But in that case by definition one would not be seeing it as a statement! Honestly to me it doesn't really matter whether "int x;" is an expression, a statement, or some mysterious third thing (in the same way that e.g. forward declaring a function isn't a statement or an expression). When we're talking about the distinction between statements and expressions we're talking primarily about statements like "x = x + 1;", which really can't be understood as a statement in the everyday English sense.

> Memory allocation... I guess? Does any compiler implementation actually do that?

Toy/research or embedded compilers do yes.