LFortran can compile a Fortran source file as other compilers do, but for interactive use it allows some extensions that one would expect in an interpreted language. You can enter an expression such as
2+3 instead of
print*,2+3. You don’t need an
end program foo statement to have a script run. You can redefine a function.
Here are some thoughts on how it should work. I wonder what others think.
Currently you must declare variables before using them. For interactive use, I suggest that LFortran infer the type of a variable from its first use. You could write
i = 2 and later
i = 3.1, but
i would already have type integer and would thus be set to 3. Writing
i = "dog" would be illegal.
call statement for invoking a subroutine be made optional for interactive use? Then
call foo() would be equivalent.
If you have some code stored in a file, is there a way to load it in an interactive session?
Could LFortran save an interactive session as proper Fortran code? You could write
a**2+b**2 during the session, but the saved code would be
print*,a**2+b**2 . A literal transcript would also be fine – a transpiler could be written to convert the transcript to legal Fortran.
Could there be a command to list the names and values of all defined variables and parameters?