-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminate implicit typing #90
Comments
@jacobwilliams , see also a couple of other recent threads: #79 and #83. See also these 2 comments where I make similar points, even an entirely painful compromise (in my mind at least) to make the (NOT!) breaking change in free-form source since every free-form source out there already has (or intends to have) "IMPLICIT NONE" to signal implicit typing is not desired : I entirely concur with your assertion, "It's also just an embarrassment at this point." As I write in one of the above comments, "Trying to get new coders to work on Fortran codes, particularly in industry, is a huge challenge. Few join with any background in Fortran, few schools teach Fortran. Then one loses them at 'hello' itself, meaning at the very beginning stage when one stresses to them the need to type 'implicit none' in every scope." As I show with this link and with even another ISO IEC working group (WG23) document on vulnerabilities with Fortran, countless amount of time and effort is expended to ensure "implicit data declarations (are) banned, by inserting "IMPLICIT NONE' in all program units". There is no reason any longer to leave such an important aspect to all the other coders and to anything else (e.g., processor options -fimplicit-none) but the goddamn standard itself. Interestingly, one arm of ISO/IEC JTC 1/SC 22 in WG23 itself states the following which is unfortunately not paid heed to by the other in WG5:
Considering the last bullet, nothing stands out as much as implicit typing and implied SAVE requiring immediate deletion from the Fortran standard. |
@jacobwiliiams and @FortranFan, I think anyone who like me started with Fortran IV/Fortan 66 and then F77 (what I like to call Jurasic Fortran) and then moved to F90 and its decendents knows that implicit typing should have been removed from the language around the time of F90 (or before). Unfortunately, this is another one of those obsolete features that somehow take precedent over more modern and more useful coding constructs because of the "we can't break code" mantra. Every time I see this I immediately interpret it as "we can't break code by adding features or deleting obsolete ones that people are paying us money to help maintain". I'm becoming more convinced that the only way to save Fortran is to first declare that what is currently called Fortran has reached its "end of life" and is entering maintenance mode. Then maybe some enterprising young person will "fork" the language and produce a compiler that ONLY supports the things in the current standard that haven't been declared obsolete and strips out all the other cruft (DEC extensions etc.) vendors insist on adding and then give it a new name and market it is as a new language. I've alway wondered what price we are paying in the way of increased compiler bugs etc. because developers have to keep dragging the weight of all the obsolete stuff around just to satisfy a few hid bound organizations that are too cheap to make the effort to update their codes. I put the following question to the F18/LLVM/Flang developers and others. How much time and code are you wasteing trying to support features that have been declared obsolete by the standard and other things like DEC extensions. I guess what I'm saying is isn't it time we had a new vision of Fortran that doesn't include or support fixed source, implicit typing, all obsolete features and existing features we can all (mostly) agree were either a mistake to add to the language or are in their current form poorly implemented. I want a new standard that officially bans them and compilers that refuse to compile if it sees any of those features. Again, the only way I see that happening is to just fork what we can all agree are the best parts of "modern Fortran", come to a consensus on what new features we think would add value to that core capability and if necessary As to @jacobwilliams proposal, I still see this as a procedural issue with the vendors more than a technical one. The path of least resistance is to make explicit typing the default and have compiler switches that people who insist on still doing implicit typing must turn on to get the old default. To me this is the logical approach since no mods would have to be made to old code and the only impact I can see is on build options just my 2 cents |
@rweed Thanks for the feedback. I just created an issue for this in LFortran (a compiler that we are developing): https://gitlab.com/lfortran/lfortran/issues/148. I thought very hard about whether we should simply create a new language, and came to the conclusion that it's better not to: by sticking to Fortran's syntax and staying compatible, it means we can leverage the excellent Fortran compilers out there, that generate highly optimized code (historically better than LLVM, although the gap has been shrinking). If we create an incompatible language, then we are starting from scratch. And we can't use it with so many Fortran codes out there. The other aspect is that if somehow Fortran compilers stop compiling our codes (and we have millions of lines) because Fortran becomes incompatible, it will only accelerate the exodus from Fortran in my opinion. Note also that there have been such efforts to remove old stuff and only stick to modern Fortran, I believe https://en.wikipedia.org/wiki/F_%28programming_language%29 was one such attempt. I don't think it was ultimately successful. I think there is a way to modernize the language, while staying compatible (for example with a compiler option). We just have to try. |
@certik wrote:
That's most commendable, thank you for pursuing such an approach with LFortran.
The name matters a lot, if they had been strongly irredentist to call their effort |
@rweed wrote:
@rweed, I'm completely sympathetic to and understanding of your sentiments. Sooner or later, the question "For whom Fortran?" will need to get addressed earnestly. And I can only hope that will result in the realization Fortran needs to transcend and rise above the confines of ISO IEC standards body bureaucracy. That it's the latter who will have to follow the language where it freely needs to go. One can notice that clearly with C++ and the rapid pace and expansive scope and brave conviction of each ISO revision. Whereas many others on the IEEE Spectrum of most popular languages in the technical arena such as Python, Java, C#, R, MATLAB, Swift, Go, and even other HPC ones such as Julia, Haskell, etc. don't even bother with such standards bureaucracy but with no less success, that's for sure. There is a lesson to be learned here: at some point, the 'bureaucracy' will need to adopt the US Marines ethos: lead, follow, or get out of the way. The current snail's pace of incremental abominations of the likes of |
Yes, I encourage everyone to do so please. When you see a related but ultimately separate discussion, feel free to open a new issue and move it there. Sometimes it's hard to do, as we are discovering the "space" of arguments and we end up discussing these meta questions as we encounter them. But as we get better at this, we will eventually have dedicated issues with these meta questions so that we do not need to repeat the arguments. |
Back to implicit typing: can anyone point to any code-base which explicitly (!) relies on this feature as part of their code design? Over the last 6 years or so, I've reviewed lots and lots of code in legacy FORTRAN (66/IV/77 + non-standard extensions) spread over 75 programs and libraries and over a couple of million lines of instruction developed using dozens of person-years of effort spanning decades of contributions by many different engineers and scientists. All of these codes - without fail - either had IMPLICIT INTEGER(I-N), DOUBLE PRECISION (A-H,O-Z) or IMPLICIT NONE For codes like these with explicit IMPLICIT statements, a future revision of the standard that removes implicit typing as the default should cause no harm! So it'll be really useful to know what other codes are out there which are of concern that Fortran cannot remove implicit typing as the default. And how relevant will these codes be in year 2035 or later when sufficient number of processors providing support for a revision with such a change start to appear? Note the earliest possible revision is Fortran 202Y. I contend the risk of breaking old code is too low or nonexistent and that's not even taking into account the surefire possibility of vendors providing options to retain implicit typing as the default. It'll be an opportunity of some commercial potential at least for the vendors, something that should not be discounted completely. So, "Why not get rid of it" as @jacobwilliams asked regarding implicit typing as the default in Fortran? |
I've always assumed most (all) compilers supported something like gfortran's -fimplicit-none compiler option. If that were the case then making implicit none the default would be a procedural or policy decision and not a technical one. You just change the default polarity of that option. Unfortunately, a quick review of compiler documentation of the compiler's I use or have used in the pass shows that (as far as I can tell) only Cray and gfortran support an implicit-none option. I can't find any reference to an equivalent option for Intel, PGI, or IBM. They may exist but I didn't see any reference to one. |
It's |
@milancurcic, I think that only turns on warnings about implicit typing. It doesn't enforce explicit typing by default. The only reference in the man pages to -implicitnone for Intel 19.0.5 is in relation to -warn options |
@rweed wrote:
They don't make it easy, Intel Fortran customers have to write
|
@rweed wrote:
NAG Fortran documentation states:
And the same with IBM XL Fortran |
As stated, the desired goal of this thread "Eliminate implicit typing" has an overwhelming non-technical component i.e., beyond the boundaries of syntax and semantics of the language. The risk of breaking old code is among them. The long history of compilers and options come into play only as much to show the risk is rather low or non-existent to be used as a crutch to further kick this can down the road.
|
@septcolor wrote:
@septcolor , thank you very, very much for bringing attention to codes such as AMOS from NetLib collection. However I do not think these legacy sources are good examples of code-bases where implicit typing is part and parcel of code design. These sources as-is have portability issues across current processors, see the comment on that GitHub repo. Then the good news is 33 out of 39 source files do not have implicit typing. Among the remaining 6 sources which do some problems with implicit declarations,
Considering everything, I would not include codes likes these in any serious attempt toward assessing the risk of deleting implicit typing as the default in Fortran. |
In ifort, |
Briefly: It seems to me that the first step is to declare the following feature obsolescent (using J3/18-007r1, page 114, pg 130/646 of PDF, 8.7 line 9). R863 implicit-stmt is IMPLICIT implicit-spec-list Also delete: First sentence of line 5 Line 11 Line 12 Line 21 Para 2 Second sentence of Para 3 Replace line 32, para 3 Replace lines 37 -38, para 4 Delete last sentence of para 4 NOTE 1 on page 115 needs to be rewriten NOTE 2 on page 115 needs to be rewritten to show how to deal with the case where a variable is synonymous with a derived type, making it difficult to declare such a derived type. Perhaps the introduction of namespaces (#1) will make this much easier. A NOTE needs to be added to show how to use other facilities when eliminating this form of the IMPLICIT statement. Change example ("program fragment") in para 5, C.9.2.2, page 556, pg 572 End of edits. The next step would be to declare implicit typing rules obsolescent. Eventually, both will be deleted. |
@ThemosTsikas wrote:
I agree with you in principle. In practice, I'll be thrilled if the order is reversed in order to achieve a "compromise"! Meaning, a relatively minor edit is made to the standard which is to effectively make IMPLICIT NONE the default. Now, I have not pondered over fully in terms of accuracy and the implications but my proposal is the paragraph corresponding to mapping of letters with types in the current standard i.e., 18-007r1 document toward Fortran 2018, Section 8.7 IMPLICIT statement, paragraph 3 be edited as follows: [114:29-34]
to
Such a small change - only one sentence in the standard is modified - will make a world of difference in the domains I work where the full intent of powers-that-be and also the coders is to have no default mapping of letters with types (e.g., no default mapping of And I'm personally convinced such a small change will have no adverse effect in other domains also because the situation everywhere is the same based on what I've researched: the intent everywhere is to have no default mapping of letters with types. Every code one can see on GitHub or SourceForge, etc. either includes or intends to have IMPLICIT NONE in all their scopes. So this small change of a proposal in this comment is only enabling what is overwhelmingly the practice. |
@ThemosTsikas thanks for your comment! And thank you for participating here. If you have any other comments or suggestions to other proposals or have some proposals of your own, please definitely comment or open new issues here. |
I think that the order I suggest has the merit that it first removes (or rather, marks as obsolescent) a bit of syntax before making changes in the semantics, and syntax is easier to check than semantics. |
In #90 (comment), I wrote what would be needed to delete the IMPLICIT implicit-spec-list feature. What is needed is similar text for the marking of the feature as Obsolescent. |
To those interested in this issue, here's a comment to take note at comp.lang.fortran thread where "Lynn McGuire" posted:
|
I've been thinking a bit more on this issue lately, especially having used Fortran some more (after seemingly having partially opened Pandora's box with this thread). First four assumptions I'm making (which to my knowledge are true, but please correct me if I'm wrong):
If these assumptions are true, getting rid of implicit typing as a default is actually pretty straightforward: Make IMPLICIT INTEGER (I-N), REAL (A-H, O-Z) Optionally this tool could even verify if this change is needed, but it doesn't have to. Additionally we could deprecate the |
Thanks @elecprog for writing down the assumptions that you used. Under your assumptions I think your proposal could work. The issue that we have is that we can't get a community agreement on the assumptions. I have seen opposition to the assumption 2., and consequently also 1. I personally agree with 2. (i.e., implicit by default being more evil), but some others disagreed (older code not compiling being more evil: Fortran historically tries very hard to compile older code, so I understand this position). |
I think we spook people when we talk about tools and code changes. The proposal should be this and only this:
That's it. Very simple and doesn't change the behavior of any code. All the maintainers of a legacy code has to do is add a single command-line argument to their build system. They don't have to change a single line of code if they don't want to. But, the important part is that new codes no longer have to type "implicit none" everywhere. We get that automatically. Implicit typing no longer has to be explained on page 1 of the Fortran Getting Started manual, it's moved into the appendix, and new users who want to write modern code never have to worry about it or even know it ever existed. An entire class of bugs that have plagued Fortran programmers for decades will disappear forever. We can finally move on. |
J3 will sometimes change the semantics of newer conforming code, but it is very unlikely that they would change the semantics of a large proportion of older code so as to require a new compiler option to make existing (c)makefiles and source code continue to work. I suggest that we define a new distinct Modern Fortran source file name suffix that would imply free source form and a few modest incompatible semantic changes: default (Addendum: This could of course also be done with a compiler directive |
@jacobwilliams here are my suggestions:
I think the proposal may have a slightly better chance if it proposes for marking default implicit typing as obsolescent rather than deleted. Traditionally features have been sunset gradually (obsolescent first, delete second), but there have been discussions about changing this process and deleting features on a shorter fuse. |
@milancurcic wrote May 31, 2022 11:11 AM EDT:
I have done the "research" and as I pointed in issue #218 my observation is only one sentence needs to be modified in the standard (18-007r1 document as proxy) which is in section 8.7 IMPLICIT STATEMENT page 114, paragraph 3, lines 32-34. In order to achieve the desired change, the relevant sentence can be changed to something along the lines of: "If a mapping is not specified for a letter, the default for a program unit or an interface body shall be NULL, and the default for a BLOCK construct, internal subprogram, or module subprogram is the mapping in the host scoping unit" Readers can peruse 18-007r1 document or issue #218 for what the standard states currently. |
@jacobwilliams , I hope you will be leading this based on your prior comment and your insistence on closing issue #218 even though so many things are on the wrong track here in this thread, starting with your poorly worded title itself. It should be obvious to any reader the root matter is mostly non-technical, it is a vision thingy really for Fortran to head in the direction of explicit declarations. All indications are most on the committee do not align with any such vision, or any vision period. Most voting members would rather live with the status quo for eternity. There is a monumental hurdle to be overcome here. So I hope you will follow all the right steps from this point forward - which are all administrative "process" and the "right manners" based as laid out by @milancurcic - in order to try to bring about the right influence on the committee(s). Perhaps you want to watch this video first and do as indicated to avoid the "no soup for you" fate. |
Everybody, let's be nice to each other. We are all in the same boat. As I mentioned at the Discourse thread, LFortran already "eliminated implicit typing" by default, and I encourage other compilers to follow suit. Regarding the standard, @jacobwilliams, do you want to take a lead on this? |
Has there been a WG5 or J3 proposal paper in the past to make |
Since Paper 03-153.txt, around line 78:
A vote on submodules and
We should probably ask Peter's question in comp.lang.fortran. |
Thanks @gklimowicz ! So that is interesting: nobody voted for the "usual Default rules". Most people voted for "Implicit none" to be the default. Also: there where only 12 people voting. There are already 10 participants who commented in this issue, and 23 (!) who upvoted the issue. So to me it means that there is clear interest in revisiting this. |
Inventing the implicit typing behavior for a new feature like submodules wouldn't affect any existing code, of course. But it's odd, given this vote, that submodules (and more important, separate module procedure interfaces) ended up with the same old rules by the time they were published in F'2008. I look forward to seeing what happens when a proposal that would require source changes to legacy codes is put forward. Is somebody going to write this up as an official paper? |
Based on the thumbs up voting trail upthread, I expect @jacobwilliams and the nice folks will write up the "official" paper. |
I hope any such papers and prior votes are only of historic interest. Any proposals, if present at all to make implicit none the default, clearly got voted down ultimately and that's why the standard is the way it is now with implicit mapping rules pervasive across all the program units. I will hope past performance of the committee(s) is not indicative of future results. |
Will you champion this paper at J3, if it is written? |
@klausler , sincere apologies if the question was not addressed to me - I have presumed as such because my comments got quoted. My response will be as follows: assuming the paper is a single topic one and it focuses on doing away with the implicit mapping along the lines of a possible one-sentence change (see above), meaning a minimally complicated brief paper honed in to make |
You should write the paper, then, to ensure that it matches your concept of the change. |
I don't see a paper at https://j3-fortran.org/doc/meeting/227 yet. This may be your only chance in the next 3-5 years to get this topic on WG5's agenda. |
A paper is not required or even desirable at this time. I have asked each member to submit a list of five features/changes they want to see in 202Y, and we will start discussing these in Boulder. It is not the “only chance”, but I expect that the list will be refined by the 2023 meeting. This is similar to the process we followed for 202X and there were many more suggestions than we could accommodate. FWIW, deprecating implicit typing is on my list. |
@klausler I have long held the view that what you suggested above is the way to solve this problem. Hardly any of Fortran's present-day defaults is conducive to modern-day programming, so this would help fix all of these defaults in one fell swoop. My top three suggestions for defaults would be the following:
|
Since F'2023 is inbound with at least one breaking change, multiple suffixes might be best. |
In a similar spirit as #40.
I think most everybody agrees that implicit typing is a terrible "feature" that should never be used. Keeping it as the default behavior is a constant source of annoyance and errors. It's also just an embarrassment at this point. Why not get rid of it?
Removing it would require that people running obsolete codes put
implicit double precision (a-h...)
or whatever that is in all their codes, right? To me that's preferable to making everybody else suffer until the end of time.The text was updated successfully, but these errors were encountered: