??? 01/01/11 20:29 Read: times |
#180389 - Pointers and type-safety Responding to: ???'s previous message |
Andy Neil said:
Per Westermark said:
until Turbo Pascal, you didn't had a chance to play with pointer types. Not true: I have here before me the original "Pascal User Manual & Report" by Jensen & Wirth (the "K&R" of Pascal) - and there is a whole chapter on Pointer Types! You couldn't typecast a pointer from one type to another, except for some very specific cases. Turbo Pascal worked a lot with typecasts and also had a "void" pointer type, and an address-of operator, removing the type safe protection Pascal was designed with, but instead allowing it to solve systems-related problems. I think the extensions are available in Free Pascal too. And you got some basic forms of pointer arithmetic too. Andy Neil said:
But you still get null pointer exceptions, which is a very common failure for .NET and Java applications. Isn't that because they are actually C/C++ "under the hood"...? No, a reference is a special form of a pointer that is defined to either point at NULL, or a valid object. The funny thing is just that they have spent a lot of time explicitly telling that the languages don't have pointers, but they did select the word "pointer" in the error message. Not sure if it was intentional, to "protect" their magic references from getting any blame ;) |