3 ms·
C had `malloc` and (real) pointers pretty much from day 1, and allows you to treat the result of `malloc` as an array. Pascal's `new` did not let you do this,
by Turing_Machine 5y ago
C had `malloc` and (real) pointers pretty much from day 1, and allows you to treat the result of `malloc` as an array.
Pascal's `new` did not let you do this, as I recall (it didn't even allow you to allocate a chunk of memory of arbitrary size... meaning that you can write `malloc` in C, but you can't write `new` in Pascal -- edit: before someone starts jumping on me with the claim that "Golly-Gee-Whiz Pascal '92" lets you do this, I am talking about Pascal, the language as designed by Niklaus Wirth, not about some bastardized non-standard extension. And yes, I fully concede that arbitrary pointers are dangerous, and are prone to producing nasty bugs. They also provide a whole lot of power).
- littlecranky67 5y agoSurely there was a way in Pascal to execute system calls (which would give you access to malloc-like constructs)?
- Turing_Machine 5y agoNot that I recall, and even if it had, that wouldn't help, as there was no way to cast the resulting chunk of memory to whatever arbitrary type you needed it to be.