In terms of programming, what do semantics mean?

前端 未结 7 730
被撕碎了的回忆
被撕碎了的回忆 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:41

    A little more context from the blog:

    Therefore in C you put the storage metadata first (static int customerCount;) rather than the semantics first (it could have been var customerCount: static int;).

    He's saying that "static int" appears before "customerCount". Calling "static int" storage metadata and "customerCount" semantics. The storage metadata is information about what the variable holds - implicit in it is how many bits it occupies, what values it may hold, whether it's shared among instances, and its volatility.

    The semantics, the variable name, is information for readers of the code about what should be stored in the variable. What the variable means. You could call it "x" and the program would work just as well, but it would be hard for a programmer to understand it. Calling it "customerCount" provides the variable with meaning, and that's semantics.

提交回复
热议问题