Re:The End of Coding
by dllthomas on Monday November 04, 2013 @02:53PM
(#6670754)
Code can certainly be ambiguous. We call it unspecified behavior, undefined behavior, or race conditions, depending.
[ Parent
| on HN ]
A race condition is a set of (possibly very many) very well defined states - or at least defined as well as everything else in the program. Someone should discover some algebra for working with concurrent processes and the race conditions would go away!
(the second sentence is a joke.)
A simple data race in C11/C++11 is undefined behavior, it doesn't have to result in any well-defined state that you might get by interleaving the execution of threads.
I think this has been on HN already: http://www.hpl.hp.com/personal/Hans_Boehm/c++mm/why_undef.ht...
Essentially it has to be that way, or on some architectures every access to a potentially shared variable would have to be wrapped in fences by the compiler.
Strictly speaking, it could be implementation-defined behavior.
Ambiguity is quite frequently between several well-defined states. A significant difference between race conditions and natural language ambiguity is that in the latter we typically expect resolution to happen favorably when the interaction is cooperative - which is not a feature of race conditions in the general or typical case. I think it's still fair to say that this is not an essential feature of ambiguity, though, which is why I included it as an example. In the case of a race condition, the relevant pieces of the language do not uniquely define a single result - additional context may.