Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Two forms for READ, which is right?

0 views
Skip to first unread message

Jerry DeLisle

unread,
Oct 6, 2007, 4:35:33 PM10/6/07
to
The following statement is accepted as valid by at least one compiler, but
rejected by several others. I would appreciate an interpretation on this:

READ ('(f3.3)'), a ! Rejected?

My take is that the initial left paren right after READ signifies that this is
the io-control-spec-list form of READ given in R909 of F95 standard. Therefore
it is not valid because there is no unit specifier.

Others interpret ('(f3.3)') as a valid character expression and therefore fits
into the second 'format' form of the READ given in R909.

I support my interpretation because the first form of the read has a
non-optional left paren so that should take precedence.

I would appreciate an interpretation from the standards experts.

Best regards,

Jerry

Richard Maine

unread,
Oct 6, 2007, 5:09:38 PM10/6/07
to
Jerry DeLisle <jvde...@verizon.net> wrote:

> The following statement is accepted as valid by at least one compiler, but
> rejected by several others. I would appreciate an interpretation on this:
>
> READ ('(f3.3)'), a ! Rejected?
>
> My take is that the initial left paren right after READ signifies that
> this is the io-control-spec-list form of READ given in R909 of F95
> standard. Therefore it is not valid because there is no unit specifier.
>
> Others interpret ('(f3.3)') as a valid character expression and therefore fits
> into the second 'format' form of the READ given in R909.
>
> I support my interpretation because the first form of the read has a
> non-optional left paren so that should take precedence.

Intriguing. I've never run into that particular near ambiguity before.
But now that you ask.

There is no relevant precedence concept. I can't point you to where such
a thing isn't in the standard because it isn't anywhere. You will just
find the two different syntax forms. Nowhere is there anything about a
precedence. The form is either valid or not. If it is valid with two
different meanings, then there would be an ambiguity. In this case...

You have correctly pointed out that this is not valid as the form of
READ with an io-control-spec-list. However, it is valid as the other
form of READ. Therefore, it is unambigiuous and is valid as... well, the
form that it is valid as.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain

Jerry DeLisle

unread,
Oct 6, 2007, 5:55:53 PM10/6/07
to
Richard Maine wrote:
> Jerry DeLisle <jvde...@verizon.net> wrote:
>
>> The following statement is accepted as valid by at least one compiler, but
>> rejected by several others. I would appreciate an interpretation on this:
>>
>> READ ('(f3.3)'), a ! Rejected?
>>
>> My take is that the initial left paren right after READ signifies that
>> this is the io-control-spec-list form of READ given in R909 of F95
>> standard. Therefore it is not valid because there is no unit specifier.
>>
>> Others interpret ('(f3.3)') as a valid character expression and therefore fits
>> into the second 'format' form of the READ given in R909.
>>
>> I support my interpretation because the first form of the read has a
>> non-optional left paren so that should take precedence.
>
> Intriguing. I've never run into that particular near ambiguity before.
> But now that you ask.
>
> There is no relevant precedence concept. I can't point you to where such
> a thing isn't in the standard because it isn't anywhere. You will just
> find the two different syntax forms. Nowhere is there anything about a
> precedence. The form is either valid or not. If it is valid with two
> different meanings, then there would be an ambiguity. In this case...
>
> You have correctly pointed out that this is not valid as the form of
> READ with an io-control-spec-list. However, it is valid as the other
> form of READ. Therefore, it is unambigiuous and is valid as... well, the
> form that it is valid as.
>
OK, thanks, more work to fix this for gfortran.

Regards,

Jerry

glen herrmannsfeldt

unread,
Oct 6, 2007, 7:03:34 PM10/6/07
to
Richard Maine wrote:

> Jerry DeLisle <jvde...@verizon.net> wrote:

>>READ ('(f3.3)'), a ! Rejected?

(snip)

> You have correctly pointed out that this is not valid as the form of
> READ with an io-control-spec-list. However, it is valid as the other
> form of READ. Therefore, it is unambigiuous and is valid as... well, the
> form that it is valid as.

Fortunately internal unformatted I/O is not allowed.

-- glen

0 new messages