CS 342 Lecture -*- Outline -*- * Arrays in FORTRAN ** design what properties characterize arrays? mapping from a totally ordered, finite (index) set to a given domain what index set? integer (subrange), characters, ... *** alternative designs subscript storage allocation binding time static dynamic static static semistatic dynamic (nonsense) semidynamic dynamic arrays have dynamic binding of subscripts, dynamic allocation, and allow changes to subscripts dynamically FORTRAN has static arrays, but FORTRAN 8x also has dynamic! No excuse for limiting number of dimensions to 3 or 7 (1 is okay if arrays are first-class) bounds checking? security vs. efficiency *** first-class? other properties of first-class types? literals, constructors initialization passing to and returning from functions ** implementation of arrays *** one dimensional linear in storage (draw pictures) *** two dimensional ---------------------- 2 dimensional array addressing: -column-major order (think of column as size) addr{A(i1,i2)} = addr{A(1,1)} + ((i2 - 1)*d1 + i1 - 1) * e_size where d1 is size of rows, d2 size of columns -row-major order addr{A(i1,i2)} = addr{A(1,1)} + ((i1 - 1)*d2 + i2 - 1) * e_size ---------------------- why does FORTRAN have to specify this?