Syntax and semantics are often used in programming. What are the meanings and differences between them?
Syntax is the syntax, and semantics is the semantics. Literally, the former focuses on the "rule", while the latter focuses on the "meaning ". Taking SQL statements as an example, in Oracle, parsing SQL statements requires a syntax check before performing a semantic check. During the syntax check, the system will determine whether the SQL statement you write contains any typos, for example, the SELECT statement is written as selct; the meaning is to determine what the purpose of your SQL writing is-whether it is to be queried or personal data.
Code
What is the difference between syntax and semantics.
This question cocould be answered merely by taking a definition out
Any dictionary or cognitive psychology text book. John R. Anderson
Defines the two in his book "cognitive psychology and its
Implications "(1995),
Semantics-grammatical rules for assigning meaning to a sentence.
Syntax-grammatical rules for specifying correct word order and
Inflectional structure in a sentence.
Doing this does not really give a clear explanation of
Differences between the two. It is beter explained if the features
The two are already ed more thoroughly.
Word Order is the basic principal of syntax, those trying
Understand what is written use the syntactic cues of word order
Help give the sentence structure and meaning. Word Order gives
Sentence the correct intonnation especially with the use of funtion
Words such as, a and who, due to this its meaning becomes much
Clearer. If the words of a sentence were not in the correct order
There wocould be no syntactic cues as to the meaning of the sentence.
This point leads on to the difference between syntax and semantics.
Semantics are an individuals own interpretation of the meaning of
"Sentence" based on their prior knowledge. Therefore a sentence that
Seemingly makes no syntactic sense, can have meaning when using
Semantic cues. The sentence "baby milk drinks" does not have
Syntactic meaning, but through semantics most people wowould interpret
It as meaning "baby drinks milk" as our prior knowledge tells us
That a baby drinks milk, and therefore we can find a meaning from
Key words.
The difference between syntax and semantics is that syntax is only
Concerned with what is linguistically and grammatically correct,
Semantics requires all ones prior knowledge which, as Anderson
States, "goes far beyond anything which is language specific ".