[J3] END statement
Dick Hendrickson
dick.hendrickson at gmail.com
Wed Dec 7 17:20:16 UTC 2022
I believe it was intentionally written that way. Back in the good old days
programs were on punch cards, compilers were one pass, listings came out on
the line printer during compilation, and input data or system control cards
usually followed the program deck. Keeping the END card "clean" was a stab
at managing this portably.
That's also the reason an end statement can't be continued nor can any line
appear to be an END statement. No need to force the compiler to do a one
line look ahead to see if it's really an END.
Punch cards were a lot more fun. ;(
Dick Hendrickson
On Wed, Dec 7, 2022 at 8:22 AM Brad Richardson via J3 <
j3 at mailman.j3-fortran.org> wrote:
> In the majority of instances I would prefer that compilers be strictly
> standards conforming by default. In this instance, I think the
> interpretation of the code is pretty unambiguous. While I think I agree
> with Steve's assessment that it's not strictly in conformance with the
> current wording of the standard, I don't really see any technical
> reason to want the standard to forbid it. Does anybody know if the
> standard was intentionally written to forbid this, and if so why?
>
> Regards,
> Brad
>
> On Wed, 2022-12-07 at 09:56 +0200, Ondřej Čertík via J3 wrote:
> > Dear committee,
> >
> > Given this interpretation, the original code:
> >
> > subroutine sub (); end subroutine; integer i
> > end program
> >
> > Is not conforming.
> >
> > Some compilers parse this and do not produce any warnings or errors.
> >
> > What is the committee recommendation on such "syntax extensions", is
> > it discouraged to do? Is it better for the Fortran community if all
> > compilers try to be as strict as possible regarding these syntax
> > rules?
> >
> > Ondrej
> >
> > On Wed, Dec 7, 2022, at 3:50 AM, Malcolm Cohen via J3 wrote:
> > > Hi Steve,
> > >
> > > I agree with your analysis.
> > >
> > > I further note that the “END statement must be the last statement
> > > on a
> > > line” requirement appears only in this definition. There is no
> > > special
> > > text in 6.3.3 fixed form which says that you cannot have another
> > > statement after the END statement – all 6.3.3 says is that it
> > > cannot be
> > > continued.
> > >
> > > However, this is sufficiently subtle that perhaps a NOTE in 6..3.1
> > > to
> > > the effect of “Because a line can only belong to a single program
> > > unit,
> > > the program unit END statement cannot be followed by another
> > > statement
> > > on the same line.”.
> > >
> > > Vipul writes:
> > > > All that 6.3.1 informs me is "integer i" is *not* part of the
> > > > program unit 'sub'.
> > >
> > > No, 6.3.1 says that a program unit is a sequence of lines, and thus
> > > it
> > > says that it **IS** part of the program unit ‘sub’. And that would
> > > have
> > > to be invalid syntax.
> > >
> > > > [it makes] little sense considering the potential scenarios of
> > > > machine-generated code
> > >
> > > If the machine can generate semi-colons, it can generate newlines
> > > instead. So I would have to disagree with this contention.
> > >
> > > Cheers,
> > > --
> > > ..............Malcolm Cohen, NAG Oxford/Tokyo.
> > >
> > > *From:* J3 <j3-bounces at mailman.j3-fortran.org> *On Behalf Of *Steve
> > > Lionel via J3
> > > *Sent:* Wednesday, December 7, 2022 10:02 AM
> > > *To:* General J3 interest list <j3 at mailman.j3-fortran.org>
> > > *Cc:* Steve Lionel <steve at stevelionel.com>
> > > *Subject:* Re: [J3] END statement
> > >
> > > On 12/6/2022 7:57 PM, Vipul Parekh wrote:
> > >
> > > > Steve, whatever little English I know does *not* say "to me that
> > > > a line can't span more than one program unit" is what is meant by
> > > > 6.3.1.
> > > That's not how I see it. "A Fortran program unit is a sequence of
> > > one
> > > or more lines" says to me that a line can't belong to more than one
> > > program unit. If the standard had said "one or more statements,
> > > comments or include lines" I'd conclude otherwise.
> > >
> > > I'll be interested in others' views.
> > >
> > > Steve
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20221207/0fa67b1d/attachment.htm>
More information about the J3
mailing list