We have a code base of tens of millions of lines.
Just over 70% of the packages contain EQUIVALENCE statements.
The uses we identified are:
- Organising data for communication between processes. One package used in financial control and analysis contained over 20,000 EQUIVALENCE statements mapping named variables into arrays (I was surprised so I checked!)
- Organising COMMON blocks. Several aircraft simulations have between 2000 and 4000 EQUIVALENCE statements for this purpose.
- Providing short local names for components of derived types and structures. For example EQUIVALENCE (pitch,attitude%pitch)
- Building data structures for attached hardware, essentially re-arranging bytes. This could be done by other means, but as pointed out by @RonShepard and others this can be awkward.
- Implementing paged data structures. This is important in our work. In explanation, fpt analyses code and stores data in multiple tables (Currently there are 27). All these tables are overlaid into the same large array. The array is divided into pages. When,for example, a new symbol table record is needed a counter is incremented. When this reaches the end of the current page a new page is used (not allocated) for continuation of the table. There are several advantages of this process. i. We don’t specify a maximum size for any table so no table can run out of space until we eventually run out of memory in the shared array. ii. As data from a large program grows, elements of the tables which describe it remain fairly close in memory. This probably helps cache handling. iii. Memory is not allocated by ALLOCATE constructs so we avoid a double reference to find, for example, a symbol table, cross-reference table or sub-program table reference. The 27 tables, and the token stream of the code are overlaid by EQUIVALENCE statements.
There must be a very good reason to remove EQUIVALENCE from the standard. However
I doubt if it will disappear from compilers or from widespread use. Can we reinstate it?
BTW my little search code is:
#!/bin/bash
for F in $(cat codes.txt);
do
echo -n $F >> equiv.txt
echo -n " " >> equiv.txt
cd $F
grep -ir equivalence | wc -l >> ../equiv.txt
cd ../
done