@jurgen.vinju thanks for the feedback. I fully agree. Just one thing for further discussion.
You are right that syntax rules we can follow thanks to IntelliSense ™ (very clever prompter, sometimes too clever).
The real problem is how to explain semantics as a set of rules. Your proposal, if I correctly understand your point, is “imagine what the compiler/interpreter/translator will do with the program text.”. Unfortunately in this approach, I need to refer to terms like compiler and interpreter. My point is that this way it is hard to explain, for example:
- how to implement abstraction?
- what is type?
- what is the difference between complex and structural types?
In all of the cases, I am expecting answers in terms of the language, usually, any language supporting object-oriented programming.
My point is that there must be a third style of how to explain semantics, namely paradigms, and patterns, for example instead of the call stack (need memory organization reference), we can use a call chain (looks like sequence).
Unfortunately, sometimes this approach is impractical also, for example, explaining the semantic difference between foreach
and from
constructs. The answer looks very easy, the foreach
is a statement, but from
is the expression. My point is that the answer refers to the syntax because semantics is iteration (foreach
) and selection (from
). We cannot explain from
referring to the computer behavior because the most important activity is executed by an external data repository engine. Do we need a fourth style or, alternatively, iteration/selection is just a pattern?
To get more about language integrated query you may check my last lecture about Structural Data (in English).
Again, many thanks for your comments and advice. Concluding, my point is that explanation of the modern programming language semantic rules is not only a matter of what the compiler/interpreter/translator will do with the text.