Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Did languages before C/C++ have pointers?

Was there any pointer usage in old languages such as FORTRAN (pre Fortran-90), cobol or pascal? If not, then what is the method those languages used to implement the works done by pointers that are used in today's high level languages.

And As there is no pointers in java is there any way other way to replicate the work done by a pointer.

like image 425
NEO Avatar asked Mar 18 '11 13:03

NEO


2 Answers

Algol 68 had references that were a lot like C/C++ pointers.

Pascal had pointers, though you couldn't do arithmetic on them.

PL/I had pointers.

In FORTRAN and COBOL, you mostly lived without such things as dynamic allocation written in the language. I did once write some linked-list code in FORTRAN that used an array, with an array index as the link to the "next" item (i.e., x[1] was a data item, x[2] was its link to the next data item, x[3] was another data item, and so on). Calling that "clumsy" was being almost excessively generous.

like image 129
Jerry Coffin Avatar answered Sep 28 '22 01:09

Jerry Coffin


BCPL had the construct a*[b] (which could be simplified to a!b in our implementation, a 6809 embedded system compiler running on a 3B2 UNIX box) which was equivalent to a[b] in C. Of course, BCPL only had the concept of words, without all the structures and so forth that give C more power.

a!b was a word offset from a word address but the implementation we used also had options for byte offset from word address a!%b, and byte offset from byte address a%%b.

like image 20
paxdiablo Avatar answered Sep 28 '22 00:09

paxdiablo