Diction and Syntax?

Syntax semantics differences

The syntax of a programming language defines which programs are well-formed. The modern approach to defining language syntax originates in the work on the ALGOL 60 language, more precisely in the use of so-called Backus-Naur form (BNF). This is essentially the same way of defining syntax as the context-free grammars introduced by Chomsky.

The semantics of a programming language must specify how a program is executed and must specify this in a machine-independent way. The designers of ALGOL 60 were very competent people (many of them were mathematicians originally) but they had no precise mathematical theory that they could use to define the semantics of ALGOL 60 so they had to rely on English prose. The danger of this is that you invariably end up forgetting some important details.

The difference between syntax and semantics can be seen from the following tiny code example from a famous paper from 1967, in which Donald E. Knuth pointed out a number of problems that existed in ALGOL 60. This tiny piece of code is syntactically correct.

1 2 3 4 5

integer procedure awkward

begin comment x is a global variable

But what will happen if we execute it?

The procedure

manipulates the value of a global
variable and therefore has a side effect. However, the ALGOL 60 report does not explain whether or not side effects are allowed in
procedures. Because of this, there is also no explanation of how
arithmetic expressions should be evaluated if they contain side

Consider a global variable

whose value is 5 and
assume that we now want to find the value of the expression
. Should we evaluate before or after we evaluate the procedure call ? If we evaluate first, the value of the expression will be 8; should we evaluate after having called, we get the value 9.
You might also like
Working with date and time
Working with date and time
0510 Working with date and time
0510 Working with date and time
angela friederici - EEG/MEG and the time course of
angela friederici - EEG/MEG and the time course of ...
Tosbuy Mesh Slip on Water Shoes for Women(eu37,gray)
  • Imported
  • Rubber sole
  • Open mesh on upper
  • lightweight and flexible
  • fabric upper
Related Posts