In terms of programming, what do semantics mean?

前端 未结 7 723
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 05:27

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

7条回答
  •  执念已碎
    2021-02-01 05:40

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

提交回复
热议问题