Semantics = Meaning

Section: Communicating with Language
...Subsection: Semantics = Meaning

A statement can be properly formed, yet produce an improper meaning, as with the sentence The milk drinks the cat. The meanings assigned to the words in a language compise its semantics. Errors in the meaning of statements are called, not surprisingly, semantic errors. A program that contains one or more semantic errors will not produce the desired results. The program will execute, but it may stop unexpectedly at some point or it may run to completion but yield an incorrect result.

Going back to our cherry pie example, if we accidently use salt instead of sugar, then we eventually get a pie at the end. It looks good, but when we taste it, we realize that something went wrong during the execution of the recipe program. On the other hand, if Julia Child neglected to mention that we needed cinnamon in the list of ingredients, then when we get to the step that tells us to add the cinnamon, we would have to stop immediately and proceed no further because we don't have any cinnamon in the house. In this case, we don't get a pie at the end.

Semantic errors are only detected during or after the program execution, and so are also called run-time errors.


Suzanne Menzel; menzel@cs.indiana.edu