Currently, for code like
we compare the ADVANCE string in the library. This is wasteful
in the vast majority of cases, where the corresponding strings
We should do the string comparison in the front end, where it
can be folded, and pass a bit field to the library.
Something for the ABI cleanup, when it happens in 4.7.
Here is a case where we do have to evaluate at run time. So maybe we can not do what is proposed above.
advancevar = "no"
write(*, "(a)", advance=advancevar) "Well, "
print *, "Does it work?"
! Interestingly, if advancevar is a PARAMETER, we get an error.
(In reply to comment #1)
> Here is a case where we do have to evaluate at run time. So maybe we can not
> do what is proposed above.
Well, I understood the request such that one passes a boolean for the 'YES' / 'NO' items. If it cannot be simplified at compile time, one adds (in trans*c) code like:
advance = _gfortran_compare_string (3, &"YES", len, &str) == 0;
Possibly, one should add a new function like
advance = _gfortran_io_yes_no (len, &str, "ADVANCE");
which takes then also into account invalid values.
Actually, for many strings, we would need
'yes', 'no" and a value for 'not specified', so four bits instead of 32.
Still better by a factor of 8, though :-)