|
|
Evolution - Functions |
|
In the 70's and 80's hardware was a limiting factor. Memory, disk space, and speed were at a premium. This limited the size and complexity of programs.
A typical program might consist of hundreds of different functions and variables.
As an example of typical collection of functions consider a matrix library
/* Return a pointer to a matrix with nrows and ncols. */
double* matrix_init (int nrows, int ncols);
/* Print the matrix to the screen. */
void matrix_print (double* a, int a_nrows, int a_ncols);
/** Replace matrix a with the sum of a and b */
void matrix_add (double *a, int a_nrows, int a_ncols,
double *b, int b_nrows, int b_ncols);
/** Free the memory associated with the matrix. */
void matrix_free (double *a);
This is manageable but unwieldy since I have to save the number of rows, number of columns, and the pointer separately and make sure I don't lose them.
This fits the algorithmic approach of thinking about the dominant problems: do this, then do that, then do another thing, etc.