Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Bug too permissive parser ?

pat97269
Beginner
716 Views
Hi all,
I discover that i can write pp.coefs instead of pp%coefs without any compile time error nor run-time error and give the expected results.
I didn't see in any documentation a word about that in the standard or in your language extension.
Can you confirm ?
0 Kudos
1 Solution
John4
Valued Contributor I
716 Views

It's an extension, related to the STRUCTURE/RECORD statements, which predate F90's derived type (See this).

You should avoid it, since it leads to ambiguities. You can put spaces around %, in order to make it more readable (e.g.: pp % constants = pp % coefs), or play with your editor's settings in order to change the color of % to light gray or something.

View solution in original post

0 Kudos
5 Replies
John4
Valued Contributor I
717 Views

It's an extension, related to the STRUCTURE/RECORD statements, which predate F90's derived type (See this).

You should avoid it, since it leads to ambiguities. You can put spaces around %, in order to make it more readable (e.g.: pp % constants = pp % coefs), or play with your editor's settings in order to change the color of % to light gray or something.

0 Kudos
pat97269
Beginner
716 Views
Ok thanks i didn't know about that structure statement.
0 Kudos
Steven_L_Intel1
Employee
716 Views
I like to recommend that people do a test build with standards checking enabled so that they are aware of extensions they are using.
0 Kudos
jimdempseyatthecove
Honored Contributor III
716 Views
John,

>>You can put spaces around %, in order to make it more readable (e.g.: pp % constants = pp % coefs), or play with your editor's settings in order to change the color of % to light gray or something.

I hadn't thought of this. The % is kind of annoying to me because it makes for me a non-visual seperation between the type variableand member variable within the type. That was why I prefer(ed) to use ".", for portability reasons I am now using %.

I haven't experimented with color highlighting... good idea. Would you know if you can set an alternate point size for %? This would be an IDE visual effect thing and not an embedded html point specification in the source file. % in comments would be displayed in normal point size/color...

Jim Dempsey
0 Kudos
John4
Valued Contributor I
716 Views

Yes, it's an IDE/Editor related effect, and doesn't affect the source file.

If I recall correctly, the Visual Studio classifies % as "Fortran operator", so you can change the color (and font size) for that one (under Tools>Options>Environment>Fonts and Colors or something similar, depending on the version). The change applies to ALL THE OPERATORS, which is fine in some other cases, such as // ---but the VS assumes that C++'s definition of operators applies everywhere, so parenthesis, comma and semicolon are affected as well.

The Eclipse IDE should have something similar (although, I bet it's extremely complicated to setup), since Intel's debugger already uses a special color for %.

Vim has a fortran.vim file for the language syntax, and a somename.vim file for the coloring ---minimal knowledge of regular expressions is required, though.

GTK-based text editors, use GtkSourceView's definition files (fortran.lang for the language syntax and somename.xml for coloring styles; quite similar to Vim's, but xml-based).

Emacs is still a mistery to me, so...

0 Kudos
Reply