Proposal: IMPLICIT NONE (INTENT)

That is indeed a bug in fortitude, thanks! We’ll get that fixed in the upcoming 0.8.0 release!

Someone else raised this same issue recently. I’m not sure we have a reliable way of detecting UDTIO procedures, short of matching on the signatures (maybe this is sufficient and wouldn’t lead to too many false negatives?). Incidentally, I think mandating this form is really a bug in the standard, and it should be character(len=:), allocatable, intent(inout).

Rather than disabling the warning completely, you can put an ! allow() comment on the line before to allow just that one instance:

        ! allow(assumed-size-character-intent)
        character(*), intent(inout)     :: iomsg

For now, we’ve put a notify clarifying this in the new docs. We’ve also got some better docs on allow comments too!

1 Like

We have at least five standalone statements that affect the defaults for all names in a scope: implicit, public, private, protected, and save. Why would this feature need to fall under the implicit statement?

Why not create a standalone intent statement?

subroutine hello_world(int1, int2, real_num, str)
    implicit none
    intent(in)
    integer :: int1, int2
    real :: real_num
    character(len=11), intent(out) :: str
    !...
end subroutine hello_world

What will it take to end the hideousness of IMPLICIT NONE (..) and for Fortran to finally move to explicit all!?!

Heck, if people with privilege to evolve the language can stop vying for the title of fuddy-duddy of the century, they might even consider explicit program units!!

explicit module m
   character(len=*), parameter :: open_secret = "fuddy-duddy is REAL unless declared otherwise!"
end module

explicit program p
   use m, only : open_secret
   print *, open_secret
end program 
1 Like

The explicit attribute for a program unit does indeed kill the “but it would break existing code” argument however I would need to add a broadly similar number of “explicits” as I have “implicits” so have I gained anything?

It would help a little in this respect. Due to the rules of where IMPLICIT statements must reside in a program file (before type statements but after USE statements), using an editor or conversion routine to add the IMPLICIT NONEs takes a bit of work to get them added in the correct place. Having EXPLICIT Progam or (EXPLICT SUBROUTINE/FUNCTION) would simplify modifying existing codes to implement EXPLICIT typing. My stand on this however is that EXPLICIT typeing should be the default not an option. People who need backwards capability could just set a compiler option to turn IMPLICIT typeing on. Most compilers have a similar switch already but with the polarity reversed.

(replying to myself…)

Furthermore, the intent attribute currently has no implicit behavior, it is simply unspecified by default. So I don’t see the logic of making it part of the collection of implicit options.

The lfortran compiler is doing this right now. One must explicitly use --implicit-typing and --implicit-interface.

In a discussion of INTENT, one should probably also include VALUE - as it has some of the characteristics of INTENT(IN), and can also be used in combination with INTENT(IN).

2 Likes