Open certik opened 3 months ago
With j3-fortran/fortran_proposals#336, one could write:
character(:), allocatable :: s, text
integer :: i
real :: a
i=1
a=1.123456789
text="this"
s = f"{i} is an integer, {a:1.2f} is a rounded real and '{text}' is text"
print(s)
Or just:
character(:), allocatable :: text
integer :: i
real :: a
i=1
a=1.123456789
text="this"
print(f"{i} is an integer, {a:1.2f} is a rounded real and '{text}' is text")
This would obviously be ambiguous with current conforming and universally portable syntax.
character(20)::a='("hello")'
print(a)
end
@klausler you are right, I forgot. I put a link to your example as the main disadvantage.
F'2023 notwithstanding, I think that it is a horrible thing to try to change the meanings of existing conforming portable programs. Please find another syntax or just stick with print *, ...
.
@klausler I agree, I wasn't trying to change meaning to existing programs. I forgot that you can put parentheses after print
, so I thought the parentheses would be enough to disambiguate it. Since this is conflicting with existing syntax, it seems it's not workable.
I find print *, "hello world"
significantly easier to use (due to using Fortran for few years)
Although, I agree a simpler syntax maybe helpful to some newcomers.
So, yes, it could be a good addition to Fortran.
The part about having '{}' as format placeholder could be achieved by this: print '(Some value {}, another value {})', a, b
. Still not Python syntax, but close.
Proposal: the syntax
print("Hello World!")
would be equivalent toprint *, "Hello World!"
.Advantages:
Disadvantages:
Discussed at: