It depends on what you mean by the expression "statement by statement". In most cases, C ++ is strictly the upper language: if you wanted to use something, you had to declare or define it earlier. Therefore, there is no problem.
However, there are exceptions to the top-down approach. For example, the body of a class member function sees declarations of members of class data that lexically follow it in the source code. You can call the inline
function, which was declared but not yet defined in the translation block (the definition must appear before the end of TU).
They may or may not violate your concept of โexpression by expression,โ depending on what the concept is.
EDIT based on your comment:
If the interpreter has no idea about the current statement, it cannot hope to interpret C ++ code. Counterexamples using the problem points above:
#include <iostream> struct C { void foo() { std::cout << i << '\n'; } int i; }; int main() { C c; ci = 0; c.foo(); }
or
#include <iostream> inline void foo(); int main() { foo(); } inline void foo() { std::cout << "x\n"; }
It should not even include built-in functions:
extern int i; int main() { return i; } int i = 0;
Angew source share