Note: thinking out loud here!
One of the things that may be tricky if you allow people to type in fragments of Fortran programs is that such programs need a particular structure. For instance: a DO-loop has a start and an end. That can be helped by having the editor insert the end-statement automatically. It becomes a bit trickier when you have declarations of variables and perhaps use statements to pull in functionality. I was thinking of using the BLOCK construct to allow some flexibility. The user puts in some statements and the editor surrounds this with a BLOCK construct for a new scope. I am not sure how this would work out, but consider the following demonstration program:
! block_use.f90 --
! Can you put a USE statement in a BLOCK construct?
!
program run_example
implicit none
write(*,*) 'First line ...'
block
use iso_fortran_env
write(*,*) 'Value of "OUTPUT_UNIT": ', output_unit
end block
end program run_example
The BLOCK construct seems to work in much the same way as subroutines or programs (with the exception of the IMPLICIT NONE statement).
Like I said, I am thinking out loud here. Using such a block construct would allow the user to combine program fragments without having to worry about the right ordering of declarations and so on.
Note: thinking out loud here! One of the things that may be tricky if you allow people to type in fragments of Fortran programs is that such programs need a particular structure. For instance: a DO-loop has a start and an end. That can be helped by having the editor insert the end-statement automatically. It becomes a bit trickier when you have declarations of variables and perhaps use statements to pull in functionality. I was thinking of using the BLOCK construct to allow some flexibility. The user puts in some statements and the editor surrounds this with a BLOCK construct for a new scope. I am not sure how this would work out, but consider the following demonstration program:
The BLOCK construct seems to work in much the same way as subroutines or programs (with the exception of the IMPLICIT NONE statement).
Like I said, I am thinking out loud here. Using such a block construct would allow the user to combine program fragments without having to worry about the right ordering of declarations and so on.