Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26753 Discussions

could a trailing comma be an alternate continuation character?

dboggs
New Contributor I
122 Views

I nominate this.

In my long lines where the "&" continuation is needed, I try to choose a logical break point and notice that it usually falls immediately after a comma. e.g. in a long list of variables in a read/write or declaration statement, and others.  "Belt and suspenders!" I think. Why can't the comma alone suffice?

In everyday English, a comma means exactly "wait--more to come." Following it with a bang ("!") just seems to add unnecessary clutter--and I'm sure that many of you abhor using C for all its curly-q clutter all over the place. Eliminating the ! after a trailing comma would make the code more readable. Has this been considered before? Is there some reason it cannot be done--some backwards compatibility issue that I can't see?

0 Kudos
8 Replies
dboggs
New Contributor I
122 Views

Sorry, I meant "following it with an ampersand just adds clutter"

jimdempseyatthecove
Black Belt
122 Views
You can separate,         &
the comma,                &
with whitespace for       &
ease in reading

Jim Dempsey

andrew_4619
Honored Contributor I
122 Views

If you have ever written code to parse Fortran you find it is a quite complex with lots of 'special cases' to consider. Adding an extra cases in many places is something to be avoided. I can see all the newer features and syntax does a good job of avoiding this. So why add new opportunities to break things for such a small gain when they are plenty of substantive things to work on?  

dboggs
New Contributor I
122 Views

Well, the ampersand would always be available for those who want whitespace at the end of their lines, but how does this help? To each his own, but to me it's distracting. I wouldn't want to read a published document having a ragged right margin, which has an extra special character stuck out where the "normal" margin would be.

andrew_4619
Honored Contributor I
122 Views

Consider the code:

   character(80) :: gchar
   gchar='I am a string with a comma,&
               & and I am continued'

In your comma continuation syntax you would have to make some additional special case. And how would you start the continuation line? 

jimdempseyatthecove
Black Belt
122 Views

Good counterpoint Andrew. Dboggs suggestion would result in:

character(80) :: gchar
gchar='I am a string with a comma,
 and I am continued'

 Which has the continuation line (character-wise) flush left. In this case, there may be some complaint about not being able to indent the line with spaces/tabs to pretty it up.

Yes, you could argue excluding comma at end of line within partially enquoted string.

Jim Dempsey

dboggs
New Contributor I
122 Views

It is a good counter-example. I think the rule would have to be that a trailing comma within a character string would have to be disregarded as a continuation character. But I wonder if the example causes trouble anyway? How does the compiler not know that your ampersand is part of the string, i.e. 'I am a string with a comma,& and I am continued'?

How does it treat a string like 'Message to Sam & Dave:' ? It would have to look at the next line to see if it starts with a & or not. Didn't think the compiler could do that. At any rate, it's pretty confusing, and so I would never break a string where either a "," OR a "&" occurs. In this example, I would make line 1

'Message to Sam ' &

followed by line 2

' & Dave:'

So I don't think the nominated suggestion would introduce more confusion than exists now.

Steve_Lionel
Black Belt Retired Employee
122 Views

The rule for continued character constants is that if the continuation line must have a & as the first nonblank character - the constant continues with the next character following the &. So if you wanted to have a continued 'Sam & Dave' you could write it as:

write (*,*) 'Sam & 
     && Dave'

The & in line 1 is the continuation indicator, and the first & in line 2 marks where the continuation resumes.

The leading & on the continuation line is required only for a continued character context.

My opinion is that the committee would have no interest in adding further complication to these rules just for visual appearance sake.

Reply