Timeline for Why most "well-known" imperative/OO languages allow unchecked access to types that can represent a 'nothing' value?
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 30, 2014 at 17:17 | comment | added | John R. Strohm | Actually not quite correct. ALGOL 68 and PL/I had pointers before C existed. PASCAL had pointers in 1970 or so. Also, linked data structures, with pointers and NIL values, were being used in assembly language well before C was invented. LISP, of course, had pointers long before any of these guys (LISP 1, 1960; LISP 1.5, 1962). | |
| Jan 28, 2014 at 21:19 | comment | added | Euphoric | @supercat This could be easily solved by having arrays default to nullable type. | |
| Jan 28, 2014 at 18:22 | comment | added | supercat | @MSalters: If a type does not have a bit-copyable default value, then creating an array of that type will require calling a constructor for every element thereof before allow access to the array itself. This may require useless work (if some or all elements will be overwritten before they are read), may introduce complications if the constructor for a later element fails after an earlier element has been built, and may end up not really accomplishing much anyway (if a proper value for some array elements could not be determined without reading others). | |
| Dec 16, 2013 at 10:21 | comment | added | MSalters | Agree. Note that in C++ (unlike Java and C), being null-able is the exception. std::string cannot be null. int& can't be null. An int* can, and C++ allows unchecked access to it for two reasons: 1. because C did and 2. because you're supposed to understand what you're doing when using raw pointers in C++. | |
| Dec 15, 2013 at 22:12 | vote | accept | aochagavia | ||
| Dec 15, 2013 at 16:25 | comment | added | aochagavia | I have marked this as the correct answer. I would like to upvote it but I have not enough reputation. | |
| Dec 15, 2013 at 16:24 | vote | accept | aochagavia | ||
| Dec 15, 2013 at 22:12 | |||||
| Dec 15, 2013 at 16:05 | comment | added | Euphoric | @svick For Java, references are replacement for pointers. And in many cases, pointers in C++ were used in a same way as what Java references do. Some people even claim that Java does have pointers (programmers.stackexchange.com/questions/207196/…) | |
| Dec 15, 2013 at 16:04 | comment | added | svick | “they probably didn't want to mess with such core concept of the language” They already completely removed pointers, also removing null wouldn't be that big of a change, I think. | |
| Dec 15, 2013 at 16:02 | history | answered | Euphoric | CC BY-SA 3.0 |