As a computer scientist and a writing hobbyist, I really ought to know these terms' meanings for memory. Can anyone clarify the difference between syntax and semantics, and provide some examples? For example, where does punctuation fall? Spelling? What about sentence (or code) structure?
|
|
|||||||||||||
|
|
I can only answer the computer question, although it has the exact same meaning for the English language. In short: Syntax is structure, and semantics is meaning. Programming languages are written based on a grammar (just like English.) Grammars might say something like "If statements always have the form: if (condition) then (statement)." If you write something that follows the grammar perfectly, then it is syntactically correct, but may or may not be semantically correct, or semantically meaningful. In some arbitrary simple language, the statement:
is syntactically correct, but not semantically correct, since it has no meaning even though it correctly follows the structure of the language. A very common example is Chomsky's statement "Colorless green ideas sleep furiously", which follows the grammar of the English language but is semantically incorrect because it because it contains several contradictions -- colorless things cannot be green, for instance. You could of course argue this poetically to have some meaning (I would probably hate you), but that's beyond the scope of this discussion. In English, "I no like!" is grammatically incorrect (syntactically incorrect), but is not semantically incorrect since it does imbue some meaning. In coding, this is more muddy; it's hard to say whether a statement like "i (int) = 3" is semantically correct even though it's syntactically correct. There's really no meaning in this distinction, either. Generally, a statement has to be syntactically valid before it even has a chance of being semantically valid. |
|||||||
|
|
Semantics is:
I think your confusion comes from the last phrase, that is, does puncutation come under "signs and symbols"? The answer is no, because, semantics deals with the meaning, so punctuation would not come under this, as punctuation does not have a meaning, and does not denote something. Punctuation comes under, syntax, which is:
Thus, in order to construct a sentences, you will need to follow certain rules, including rules for using punctuation. Punctuation comes under syntax. What doe spelling come under? I would say, "morphology":
Thus, morphology, deals with how words are formed, and spelling would come under this. Hope that helps. All sources are from Wikipedia. |
|||||||
|
|
As far as computer science applies, simple answer is... Syntax errors are those errors caused because you did not follow the rules of the language: For C++
Semantics errors are those errors caused due to mispelling and such For C++
|
|||
|
|
|
Syntax is the symbology and grammar of a language, which tells you the rules for constructing well-formed sentences of the language. Semantics concerns what those statements mean.
These all mean the same thing, which is to say they have the same semantics, but they are described using slightly different syntax. Some languages offer alternative syntaxes for commonly used language constructs. For instance, in Lua the following are exactly equivalent; i.e. they have identical semantics:
As do the following:
|
||||
|
|