Site menu:

Semantics

We would probably argue that although these sentences could be determined as correct from the view of syntax, that what they are saying was not possible. That is their meaning would not be acceptable. In programming languages we call the aspect which defines the meaning of a language construct as semantics.

The semantics are important in a programming language as they tell us what we should expect a certain construct or statement in the language to do. What did we define as a program? Do we simply group constructs together or do we organise constructs that perform certain functions to achieve a given objective or task?


Understanding semantics

Just examining the syntax alone does not help us understand how to program using our programming language. We need to understand the semantics or meanings of the constructs. That is why langauge texts expaln the meaning of all constructs. There are still difficulties. How do variables of type string work and what are the restrictions on the use of operators with some variable types.

A compiler for strongly typed languages will check that variables of the right type are being used in the correct places during the compile. This is the compiler checking some of the semantic rules rather that the syntax rules.


Used in a course, this would be linked to a discussion forum so that students could discuss the issues raised on this page.