News for hackers. Stuff that matters.
Re:Statements vs. Expressions by zabzonk on Thursday July 14, 2022 @10:04AM (#32096244)
Understand where you are coming from, but given the nature of C, what is the compiler to do with something like:

    1 2 3
which are three expressions, and probably the programmer meant "123". Of course:

    1; 2; 3;
is OK.
Re:Statements vs. Expressions by gumby on Thursday July 14, 2022 @11:03AM (#32096919)
But that’s the point: what value does a language gain by making the distinction? It removes composability for no gain.
Re:Statements vs. Expressions by zabzonk on Thursday July 14, 2022 @11:43AM (#32097522)
There is some gain in that you need to explicitly say that something is evaluatable, like:

   (+ 1 2)
as opposed to:

    1+2
Whether the gain is worth it is, I agree, debatable.
Re:Statements vs. Expressions by gumby on Thursday July 14, 2022 @02:30PM (#32099777)
Lisp’s homoiconic representation is not relevant to this issue.

In C, `1+2` is an expression that returns 3. `1+2+3` acts like two expressions (and perhaps it is; I forget the precise terminology used in the standard). You can write `return foo(1+2)`.

But `for` introduces a statement so can only be used where a statement can.