Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In terms of programming, what do semantics mean?

Tags:

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?

like image 200
Richard Nienaber Avatar asked May 27 '09 17:05

Richard Nienaber


People also ask

What is an example of semantics in programming?

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 ".

What is semantics in simple words?

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.

What Is syntax and semantics in computer programming?

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.

What does semantics mean in Python?

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.


1 Answers

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") 
like image 194
Konrad Rudolph Avatar answered Sep 20 '22 13:09

Konrad Rudolph