Home > Archive > Fortran > March 2004 > Re: Is it possible to specify runtime edit descriptors in format statements ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Is it possible to specify runtime edit descriptors in format statements ?
|
|
| Richard Maine 2004-03-27, 12:18 am |
| Gus Gassmann <hgassman@mgmt.dal.ca> writes:
[about formats]
> I don't remember details any more, but I was once burned by a compiler that
> did not like the spaces (perhaps it was in a floating point format?).
If so, that compiler violated the standard, no matter where the spaces
were (except in a character context or, for suitable vintage,
Hollerith). Heck, formats are the one place where blanks are ignored
even in f90 free source form. Ignoring blanks in formats in free
source form was a source of some controversy in an interpretation as
I recall, but the fact that run-time formats aren't associated with
a source form at all was a significant factor in deciding that all
formats were interpreeted by the same blank significance rules, which
for compatibility then had to be that blanks were insignificant (with
the obvious exceptions).
If you find a compiler that violates this, I'd suggest submitting a
bug report.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
| |
| Robert Corbett 2004-03-27, 12:18 am |
| Richard Maine <nospam@see.signature> wrote in message news:<m17jx8apiy.fsf@macfortran.local>...
>
> If so, that compiler violated the standard, no matter where the spaces
> were (except in a character context or, for suitable vintage,
> Hollerith). Heck, formats are the one place where blanks are ignored
> even in f90 free source form.
Sort of. Of course, blanks are not ignored within Hollerith and
apostrophe edit descriptors. There is one obscure case where
blanks outside of Hollerith and apostrophe edit descriptors are
significant in format specifications, even in fixed format and
even in FORTRAN 77. The FORMAT statement
99999 FORMAT('ABC''DEF')
is a standard-conforming statement. The statement
99999 FORMAT('ABC' 'DEF')
is not a standard-conforming statement. As you might recall, there was
at one time a proposal to concatenate adjacent string literals, which
would make the latter statement equivalent to
99999 FORMAT('ABCDEF')
I checked and found that there are compilers that work that way
(including Sun's).
Sincerely,
Bob Corbett
| |
| Richard Maine 2004-03-27, 12:18 am |
| robert.corbett@sun.com (Robert Corbett) writes:
> Richard Maine <nospam@see.signature> wrote in message news:<m17jx8apiy.fsf@macfortran.local>...
>
> Sort of. Of course, blanks are not ignored within Hollerith and
> apostrophe edit descriptors.
Yes. I was just trying to keep my statement simple, assuming that
condition would be understood. (Can't win. If I write down all
the conditions necessary for complete literal truth, it's too
complicated. If I omit a condition, I'll get corrected. Not
complaining, btw; just amused.)
> There is one obscure case where
> blanks outside of Hollerith and apostrophe edit descriptors are
> significant in format specifications, even in fixed format and
> even in FORTRAN 77. The FORMAT statement
>
> 99999 FORMAT('ABC''DEF')
>
> is a standard-conforming statement. The statement
>
> 99999 FORMAT('ABC' 'DEF')
>
> is not a standard-conforming statement.
Intriguing. I'd forgotten about that case. A quick check
shows that you are correct. And a little thought gives me
the conclusion that it pretty much does have to be that way.
Of course, I might argue that in the standard conforming
case, the '' is in a character context and that's why the
blanks matter. (Being "in a character context" is the
wording that the standard uses when talking about blank significance
in general.)
But to me the intriguing thing here is a matter of circularity.
The presence or absence of the blank changes whether this is
in a character context or not (a blank between 2 character
literals would not be in a character context), which in turn
influences the question of whether the blank is significant.
Cute. I do think that the standard is explicit enough to
cover it ok (even if the mentioned extension were standardized),
but I hadn't fully appreciated the subtlety of it before.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
|
|
|
|
|