Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #2815
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: Undefined behaviour, was: for or against equality |
| Date | 2022-01-09 23:53 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <22-01-039@comp.compilers> (permalink) |
| References | (1 earlier) <22-01-016@comp.compilers> <22-01-018@comp.compilers> <7f4f52f2-49ee-9e80-1f03-c3fb9c74f574@gkc.org.uk> <22-01-029@comp.compilers> <22-01-033@comp.compilers> |
On 08/01/2022 18:52, Anton Ertl wrote: > David Brown <david.brown@hesbynett.no> writes: >> Undefined behaviour, as far as language standards are concerned, are >> omnipresent in programming - for all languages. > > Please prove this astounding assertion. My impression is that managed > languages define everything, at least to some extent, and leave > nothing undefined. If they allowed nasal demons, the appeal of > managed languages would evaporate instantly. > Certainly managed languages define far more than unmanaged languages. But equally certainly, they do not define everything. In Python, I can write : x = flooble(123) Nowhere in any part of the documentation for Python is a definition of what the function "flooble" should do. Calling it is /undefined behaviour/ as far as the language standards are concerned. Certainly some aspects of calling it - such as the calling convention - are defined. What should happen if the function does not exist is defined. But the language and the standards do not define the behaviour of "flooble". Being "undefined behaviour as far as the language standards are concerned" does not mean you can get nasal daemons, it means that the language standards do not say what will happen. When one says "Division by 0 is undefined behaviour in C", that is what is meant - as a compiler or a host OS could give you well-defined and predictable behaviour when you attempt to divide by 0. A managed language may put limits on the kind of effect of undefined behaviour. In Python (at least, CPython), it is possible to call externally defined functions in shared libraries - even if the Python bytecode interpreter limits possible effects of pure Python code, calling external functions gets around those limits. I suppose you could have a more locked-down managed language that does not allow any external code, and has additional tracking on things like data space usage, time usage, and other resources to stop run-away code. Within such a closed language, you could have defined behaviour for all code, since any code run or functions called would be in the same language and have their definitions clear to the interpreter. Personally, I don't see minimising undefined behaviour as part of the appeal of managed languages. I make as much effort not to divide by zero or work with invalid references in my Python code as I do in my C code - it doesn't much matter if the program stops with Python exception or a crash. I use Python for the convenience of working with strings, dictionaries, and other data structures with little concern for memory management, for its libraries, and other high-level features. When running unknown code - such as javascript from a website - it is vital that the effect of any code is limited. Code may have behaviour that is undefined by the language standards, but it will be defined by other parts of the code or by its environment (browser, built-in libraries, etc.). And while it may crash the javascript program or hang the browser, it should never be able to launch nasal daemons.
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
Re: for or against equality, was Why are ambiguous grammars usually a bad idea? Martin Ward <martin@gkc.org.uk> - 2022-01-05 10:25 +0000
Re: for or against equality, was Why are ambiguous grammars usually a bad idea? David Brown <david.brown@hesbynett.no> - 2022-01-06 09:11 +0100
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-06 16:43 +0000
Re: what is defined, was for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-07 12:06 +0100
Re: what is defined, was for or against equality Spiros Bousbouras <spibou@gmail.com> - 2022-01-07 13:21 +0000
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-08 09:31 +0000
Re: what is defined, was for or against equality Spiros Bousbouras <spibou@gmail.com> - 2022-01-08 22:28 +0000
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-09 00:09 +0000
Re: what is defined, was for or against equality Spiros Bousbouras <spibou@gmail.com> - 2022-01-09 21:30 +0000
Re: what is defined, was for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-09 23:00 +0100
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-10 12:04 +0000
Re: what is defined, was for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-11 18:16 +0100
Re: what is defined, was for or against equality Kaz Kylheku <480-992-1380@kylheku.com> - 2022-01-11 19:19 +0000
Re: what is defined, was for or against equality gah4 <gah4@u.washington.edu> - 2022-01-11 14:18 -0800
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-12 19:02 +0000
Re: what is defined, was for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-13 08:24 +0100
Re: what is defined, was for or against equality Thomas Koenig <tkoenig@netcologne.de> - 2022-01-13 11:17 +0000
Re: what is defined, was for or against equality gah4 <gah4@u.washington.edu> - 2022-01-10 16:58 -0800
Re: for or against equality, was Why are ambiguous grammars usually a bad idea? Robert Prins <robert@prino.org> - 2022-01-06 19:07 +0000
Undefined behaviour, was: for or against equality Martin Ward <martin@gkc.org.uk> - 2022-01-07 14:02 +0000
Re: Undefined behaviour, was: for or against equality Spiros Bousbouras <spibou@gmail.com> - 2022-01-08 03:41 +0000
Re: Undefined behaviour, was: for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-07 15:56 +0100
Re: Undefined behaviour, was: for or against equality anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2022-01-08 17:52 +0000
Re: Undefined behaviour, was: for or against equality David Brown <david.brown@hesbynett.no> - 2022-01-09 23:53 +0100
Re: Undefined behaviour, was: for or against equality Kaz Kylheku <480-992-1380@kylheku.com> - 2022-01-11 16:55 +0000
Re: Undefined behaviour, was: for or against equality George Neuner <gneuner2@comcast.net> - 2022-01-11 22:01 -0500
csiph-web