To add a bit more detail, I image that formats will be turned into
run-time objects containing a 'compiled' version of the format
mini-language. A statement like
WRITE(*, 2) A, X
2 FORMAT(I2, F5.2)
would turn into
format_2.start();
format_2.write(UNIT_STAR, A);
format_2.write(UNIT_STAR, X);
format_2.end();
where the write method is a templated method that advances an internal
pointer in the format "list" (it may, in fact, be a cyclic graph). And
WRITE(*,2) (N(I), X(I), I = 1, 6)
would turn into
format_2.start();
for (int i = 1; i <= 6; i++) {
format_2.write(STAR, N[i]);
format_2.write(STAR, X[i]);
}
format_2.end();
The member function 'end' should be idempotent, because the write
function will also call it when the last format specification is used.
I'm sure this is turn out to be way more complicated that it looks to me
right now, but this feel like the gist of what's needed.
--
Ben.