I am relatively new to the language and noticed in a lot of literature
the terms "end do" and "enddo" are used (apparently) interchangeably.
What is the signifigance of the two forms, are they different? If so,
is there a historical reason for the distinction and which is the more
correct or appropriate to use?
Regards
JV
N1830.pdf (the final draft of the Fortran 2008 standard) mentions the
following in section 3.3.2.2 Blank characters in free form, paragraph 3:
"One or more blanks shall be used to separate adjacent keywords except
in the following cases, where blanks are optional:
BLOCK DATA
END INTERFACE
DOUBLE PRECISION
END MODULE
ELSE IF
END PROCEDURE
ELSE WHERE
END PROGRAM
END ASSOCIATE
END SELECT
END BLOCK
END SUBMODULE
END BLOCK DATA
END SUBROUTINE
END CRITICAL
END TYPE
END DO
END WHERE
END ENUM
GO TO
END FILE
IN OUT
END FORALL
SELECT CASE
END FUNCTION
SELECT TYPE
END IF"
And it mentions the following in section 3.3.3.1 on fixed source form,
paragraph 2:
"Except in a character context, blanks are insignicant and may be used
freely throughout the program."
So, in short, it's up to personal preference, or company policy, or
whatever, but it's interchangeable.
Erik.
I enquired this at a J3 meeting. The two-word forms are preferable,
and some of the new keyword pairs do not have single word forms.
But what Erik Toussaint says is correct - they are equivalent, and
there is no plan to remove any of the forms.
Regards,
Nick Maclaren.
You can use whichever you prefer.
I prefer "end do".
The words are more readable when a blank is present.
>And it mentions the following in section 3.3.3.1 on fixed source form,
>paragraph 2:
>
>"Except in a character context, blanks are insigni cant and may be used
>freely throughout the program."
Fixed source form is error-prone, thus should be avoided.
Dear all, thanks for the prompt responses and the standards
perspective, I will conform to the "correct" :) preferential way.
Regards
JV
--
Tim Prince
Dick Hendrickson
> The historical reason is that back in the good old days blanks were
> insignificant and it was reasonably common practice for people to spell
> out two-word keywords. BLOCK DATA is easier on the eyes than BLOCKDATA.
> With F1990 blanks became significant in the new free source form, but
> remained insignificant in the old source form. As a way to easy the
> transition, blanks were allowed in multi-word keywords at the natural
> word breaks.
Right. And the reason blanks were insignificant is that they
corresponded to a column in a punch card in which no hole was punched.
So, in the event of a mistake, one could tape over it, making it a
blank, but it might be too fragile to re-punch it, so one carried on in
the next column.
The "historical reason" is that traditionally, and still in fixed
form Fortran, blanks are not significant. You can add them in
the middle of keywords, or remove them and make things completely
unreadable.
DO1I=1,10
1 WR I TE(*,*) I
ST
1OP
E N D
This feature was removed in free form, but special cases were
added for some common multi-word cases.
-- glen
> The historical reason is that back in the good old days blanks were
> insignificant and it was reasonably common practice for people to spell
> out two-word keywords. BLOCK DATA is easier on the eyes than BLOCKDATA.
Note that PL/I, where blanks were always significant, allows
for both GO TO and GOTO. I don't remember any other two-word
cases, though.
> With F1990 blanks became significant in the new free source form, but
> remained insignificant in the old source form. As a way to easy the
> transition, blanks were allowed in multi-word keywords at the natural
> word breaks.
-- glen
> Right. And the reason blanks were insignificant is that they
> corresponded to a column in a punch card in which no hole was punched.
> So, in the event of a mistake, one could tape over it, making it a
> blank, but it might be too fragile to re-punch it, so one carried on in
> the next column.
I never did that one, or knew anyone who did. I'm not entirely convinced
that was the reason for blank insignificance. I suppose it is possible,
but I'm not convinced. Do you have positive information about this being
the reason, or is it just conjecture?
I don't think I'd have wanted to feed such a taped card through a
high-speed card reader. In fact, I rather strongly suspect I might have
gotten some pretty nasty looks from the computer operators if I had
tried to give them a deck with such taping. Sounds like a way to jam up
the reader.
What I have done is delete rows in paper tape. In that case, it is the
opposite. All the holes on a row punched counted as deleting the row
(not leaving a blank - just deleting it). No tape required.
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
I never heard of that one, either. While some keypunch operators
were prone to inserting spurious spaces, I am pretty sure that the
reason was to allow code like the following:
PI BY 4 = 0.7853 9816 3397
or at least the latter. Allowing numbers with embedded spaces was
a near-universal convention in tables, and was allowed in some
pre-Fortran languages, as far as I recall. It assuredly was in
many input routines that were callable from machine code, for
very good reasons.
On this matter, why on earth do those bozos who write ATM software
and Web purchasing forms not allow spaces in card numbers? Dammit,
the CARDS have the spaces on them! It's not exactly innovation :-(
>I don't think I'd have wanted to feed such a taped card through a
>high-speed card reader. In fact, I rather strongly suspect I might have
>gotten some pretty nasty looks from the computer operators if I had
>tried to give them a deck with such taping. Sounds like a way to jam up
>the reader.
And how, even on an IBM reader - ICL readers had a shuffle-and-deal
feature at the best of times, and tatty cards tended to produce papier
mache of up to a dozen or so cards.
>What I have done is delete rows in paper tape. In that case, it is the
>opposite. All the holes on a row punched counted as deleting the row
>(not leaving a blank - just deleting it). No tape required.
Yup :-)
Regards,
Nick Maclaren.
> I never did that one, or knew anyone who did. I'm not entirely convinced
> that was the reason for blank insignificance. I suppose it is possible,
> but I'm not convinced. Do you have positive information about this being
> the reason, or is it just conjecture?
I think I once read it in c.l.f, so it must be true. :-)
I never worked with punched cards myself, though I have seen them and
have met people (only a few years older than myself) who did. (I did
start late, though, not having had anything to do with computers until I
was 26.)
I don't believe I ever saw or knew about that for programming,
but I do remember seeing it for bank card receipts. It used to
be that credit card invoices were the shape of punched cards,
and then as part of the processing they actually were punched.
As it was the original with signature, a copy wasn't quite the
same.
> I don't think I'd have wanted to feed such a taped card through a
> high-speed card reader. In fact, I rather strongly suspect I might have
> gotten some pretty nasty looks from the computer operators if I had
> tried to give them a deck with such taping. Sounds like a way to jam up
> the reader.
Reminds me of one time someone put a leaf in my card deck. The
card reader pulls the card from the stack in the direction of
the top of the card, and then feeds it column one first through
the read head. The card and leaf went through the first step,
then the reader declared a misfeed. I opened the door in the
back, removed the leaf (while making sure no-one was looking)
then continued on.
I believe, though, that there was special tape designed for
that function. Red, so as to block (enough) light for optical
readers, and also electric brush readers. With the 029
keypunch it was possible to duplicate while inserting
characters. Duplicate up to the point of insertion, press
the original against the high friction (black) backing while
inserting new charecters, then continue the duplicate. That
stops the original card from moving, such that the insert works.
> What I have done is delete rows in paper tape. In that case, it is the
> opposite. All the holes on a row punched counted as deleting the row
> (not leaving a blank - just deleting it). No tape required.
The original use for the ASCII DEL character, before DEC started
using it as the backspace character. (Confusing to us ever since.)
-- glen
Definitely NOT; a piece of tape on a punch card would cause a card crash.
The metal throat on the card reader was just a tad wider than the thickness of the card.
Thus any tape on the card in this vicinity would have jammed in the throat.
Another possible result could have been that the tape peeled off and ended up wrapped around
some part of the rotating machinery used to move the card thru the mechanism
of the card reader.
The not uncommon practice to correct a punch card was to plug the hole
with a "chip" from the bin of confetti from the card punch, and then to reproduce the card.
There are DO WHILE and DO UNTIL. but these pairs cannot be combined into one word.
For compatibility, any keywords from Fortran 77 have to work without
spaces (at least in fixed-form source) while this restriction doesn't
exist for new features (like DO WHILE and DO UNTIL).
> For compatibility, any keywords from Fortran 77 have to work without
> spaces (at least in fixed-form source) while this restriction doesn't
> exist for new features (like DO WHILE and DO UNTIL).
Fixed source form is an unrelated issue. Spaces are just irrelevant
there. But there is a particular list of keywords that allow spaces in
free source form as well.
Compatibility with fixed source form doesn't really dictate that. If
that were the issue, then it would have to be allowed, for example, to
spell CONTINUE as C O N T I N U E, which is something I have seen in
old fixed-source-form code. I think it was supposed to spread it out for
some kind of visual reason.
> Phillip Helbig---undress to reply <hel...@astro.multiCLOTHESvax.de>
> wrote:
>
> > For compatibility, any keywords from Fortran 77 have to work without
> > spaces (at least in fixed-form source) while this restriction doesn't
> > exist for new features (like DO WHILE and DO UNTIL).
>
> Fixed source form is an unrelated issue. Spaces are just irrelevant
> there. But there is a particular list of keywords that allow spaces in
> free source form as well.
Since spaces could be omitted in Fortran 77, old code could have ENDIF
(as well as END IF or, for that matter E ND I F). Thus, with Fortran
90, one couldn't require a space between "END" and "IF" (at least not in
fixed-form source) without breaking a lot of old code. However, with
stuff which didn't exist in Fortran 77, there was no reason not to
require a space. (It's late; maybe I'm confused.)
> Since spaces could be omitted in Fortran 77, old code could have ENDIF
> (as well as END IF or, for that matter E ND I F). Thus, with Fortran
> 90, one couldn't require a space between "END" and "IF" (at least not in
> fixed-form source) without breaking a lot of old code. However, with
> stuff which didn't exist in Fortran 77, there was no reason not to
> require a space. (It's late; maybe I'm confused.)
I think so.
All the old ways still work in fixed form. Spaces anywhere or no
spaces at all. Even new Fortran 90 or later statements still
work without spaces in fixed form. (That might have made it
harder to add some of them.)
Since there was no free form in Fortran 77, there is no compatibility
problem there.
-- glen
> In article <1jwy12r.1a3cg511jxt4wyN%nos...@see.signature>,
> nos...@see.signature (Richard Maine) writes:
>
> > Phillip Helbig---undress to reply <hel...@astro.multiCLOTHESvax.de>
> > wrote:
> >
> > > For compatibility, any keywords from Fortran 77 have to work without
> > > spaces (at least in fixed-form source) while this restriction doesn't
> > > exist for new features (like DO WHILE and DO UNTIL).
> >
> > Fixed source form is an unrelated issue. Spaces are just irrelevant
> > there. But there is a particular list of keywords that allow spaces in
> > free source form as well.
>
> Since spaces could be omitted in Fortran 77, old code could have ENDIF
> (as well as END IF or, for that matter E ND I F). Thus, with Fortran
> 90, one couldn't require a space between "END" and "IF" (at least not in
> fixed-form source) without breaking a lot of old code. However, with
> stuff which didn't exist in Fortran 77, there was no reason not to
> require a space. (It's late; maybe I'm confused.)
Yes, I'm guessing you must be. I can't think of much more to elaborate
than to repeat my prior post. I don't think you understood it. The
matter has nothing to do with fixed source form. The fixed source form
rules did not change with f90 and later (other than to make it
obsolescent). The rule in question relates *ONLY* to free source form,
which does not have such a compatibility issue.
If you do insist on talking about fixed source form, then it is still
valid Fortran. People certainly can write DOWHILE or DOUNTIL in fixed
source form today. I wouldn't do it, but it is perfectly valid. Any
argument about needing to be compatible with old code in fixed source
form would apply just as well to new code in fixed source form. If you
want to caim that somehow the fixed source form issues of DOWHILE are
any different from those of ENDDO, I just don't buy it. (One might also
note that DO WHile and END DO came into the standard at the same time,
which further argues against a distinction on that basis.)
Look at the actual list in the standard of keywords with optional
blanks. It isn't consistent at all with this argument. Heck. *MOST* of
the things in the list are ones that were added in f90 and later. One is
new to f2008 (if you look at the version of the list in the f2008
standard).
And again, I don't recall hearing anyone involved make arguments like
that. I just hear you speculating that this might have been the reason.
Admitedly, it can at times be hard to definitively state the reason for
some things even when one was there for the vote. Neither of us was
there for this one. But I just don't buy it.
I was replying to Glen's comment about PL/I.
In PL/I, there are DO WHILE and DO UNTIL,
> There are DO WHILE and DO UNTIL. but these pairs cannot be
> combined into one word.
No, it is the WHILE option to the DO statement. There are a
large number of other statements with keyword options that also
can't appear as one word.
GET DATA, GET LIST, GET EDIT, GET FILE, GET STRING,
the same with PUT, then READ and WRITE have many options,
along with many other statements.
GOTO is not the TO option of the GO statement.
-- glen
Just as you can write DOW HILE or:
0D
1O
2W
3H
4I
5L
6E
>argument about needing to be compatible with old code in fixed source
>form would apply just as well to new code in fixed source form. If you
>want to caim that somehow the fixed source form issues of DOWHILE are
>any different from those of ENDDO, I just don't buy it. (One might also
>note that DO WHile and END DO came into the standard at the same time,
>which further argues against a distinction on that basis.)
I did have to read the relevant section more than once to convince
myself that the fixed/free form distinction was totally independent
of the rest of the syntax.
I used to use ENDDO, on the grounds that it was a keyword, but changed
when I found out that Fortran has adopted the concept of keyphrases,
as the preferred form.
Regards,
Nick Maclaren.
It may be an option, but it still can't be combined into one word.
Nor can DO FOREVER be combined into one word.
> There are a
>large number of other statements with keyword options that also
>can't appear as one word.
>
>GET DATA, GET LIST, GET EDIT, GET FILE, GET STRING,
>the same with PUT, then READ and WRITE have many options,
>along with many other statements.
>
>GOTO is not the TO option of the GO statement.
That's irrelevant.
The point is that adjacent PL/I keywords cannot be combined
onto one word (thank goodness).