by icebraining · 9y ago · 0 comments
Really? Why? And can you give an example of that in, say, Python?
Syntactically correct. Will provoke error during runtime due to invalid semantics.
But I was answering this specific to the question of "syntactically valid yet semantically invalid statements" in python.
(-1) ** 0.5
Why define something that has no meaning? Just a waste of cycles, CPU and brain. >>> (-1) ** 0.5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: negative number cannot be raised to a fractional power
Any conforming implementation of Python 2.7 must raise ValueError. Why define it? So that a programmer can catch ValueError.