3 ms·
What do you mean with "semantics" in the first sentence?
by goto11 7y ago
What do you mean with "semantics" in the first sentence?
- carapace 7y agoThe usual: https://en.wikipedia.org/wiki/Formal_semantics_of_programming_languages https://en.wikipedia.org/wiki/Formal_semantics_of_programmin... Consider: 1 + "two" That's syntactically valid in Python and JS but semantically valid only in JS, not Python: >>> 1 + "two" Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'int' and 'str' >> 1 + "two" "1two" Python raises a TypeError not a SyntaxError; JS Frankensteins the values together.
- goto11 7y agoSo how does this prevent any bugs which aren't already prevented by the language?