This is a sentence from Eric Lippert's blog:
Given that unfortunate situation, it makes sense to emphasize the storage mechanism first, and then the semantics second.
It's easy to get a dictionary definition of what "semantic" means but what does it mean in terms of computer jargon?
Semantics, roughly, are meanings given for groups of symbols: ab+c, "ab"+"c", mult(5,4). For example, to express the syntax of adding 5 with 4, we can say: Put a "+" sign in between the 5 and 4, yielding " 5 + 4 ".
Semantics is the study of meaning in language. It can be applied to entire texts or to single words. For example, "destination" and "last stop" technically mean the same thing, but students of semantics analyze their subtle shades of meaning.
A sentence in a programming language is an expression or a program whose form is dictated by the grammar (or rules) of the programming language. Syntax is the term that we commonly use for the grammar. Semantics refers to the meaning that a sentence has.
Python uses dynamic semantics, meaning that its variables are dynamic objects. Essentially, it's just another aspect of Python being a high-level language. In the list example above, a low-level language like C requires you to statically define the type of a variable.
but what does it mean in terms of computer jargon?
Essentially the same thing. Example:
x = 5;
The above is the syntax (representation). The meaning (i.e. the semantics) of this term is to assign the value 5 to a symbol (variable, whatever) called x
. Different languages offer different syntaxes to provide the same semantics. For example, the above assignment would be written as
x := 5;
in Pascal, and as
x <- 5
in several other languages. In all cases, the meaning is essentially the same. But sometimes, the same syntaxes can also have different meanings, depending on the language and/or context. VB for example redefines the equals operator to mean two different things. First, an assignment, just as above.
Secondly, in the following code sippet, rather than assigning, it takes the meaning of comparing two values:
If x = 5 Then Console.WriteLine("x is 5")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With