-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement low level version of read_formatted #1
base: main
Are you sure you want to change the base?
Conversation
And use it in the high level version of read_formatted.
The main point of interface read(formatted)
module procedure :: read_formatted
end interface as user defined derived type input, this is not possible for intrinsic data types like program demo
use stdlib_string_type, only : read(formatted)
implicit none
character(len=:), allocatable :: dlc
integer :: io
open(newunit=io, form="formatted", status="scratch")
write(io, *) "Important saved value"
write(io, *)
rewind(io)
read(io, *) dlc
close(io)
end program demo It will crash with a segmentation fault in the Fortran runtime, but not reach the
As I said, user defined derived type input output is a bad example, because it cannot be defined for intrinsic data types. |
Ok, I didn't realize you are overloading intrinsic As a consequence, I don't think we should be overloading the intrinsic |
Or to rephrase: if overloading works for |
There is no issue with the Fortran standard, but GCC seems to miss a violation of the standard here (not 100% sure about this, I would have to look for the respective sections on UDDTIO in the specs). |
Yes. The low level API it is wrapping right now are only intrinsic procedures. There is no need middle level because the low level API is in fact defined by the Fortran standard for |
Well, you actually provide some actual low level functionality. I went over your code and extracted all genuine functionality into a low level API, and then I use the low level API in your high level API. So at this point, the file |
I don't really see the benefit of splitting those routines into a "low-level" API, if their only purpose is to be called in the exploratory high-level API. The issue of a Edit: essentially I agree with the words of @awvwgk:
Towards the bottom of the thread in the j3-page proposals there is a link to comp.lang.fortran exchange: https://groups.google.com/g/comp.lang.fortran/c/9_0q0dBRzpk, the messages from 9. Jan and further contain a discussion of some of the ambiguities allocate on read would lead to. |
Indeed, the The other is Finally, the What exactly is then the advantage of the It seems that it allows to override |
It is just a non-fancy string type, which basically provides the same functionality as a deferred length character but can be used in an |
Please, no! :) Let's not hack around compiler warnings with subroutines that don't do anything. Instead, we should disable the compiler warnings we don't like. |
Would you mind adding this paragraph to the file as a comment (at the top) or to the specs or both? |
Putting my compile writer hat on, how do you disable a warning just for a subroutine? Is this warning even useful at all? |
On @certik suggestion I went ahead to propose the function at fortran-lang/stdlib#316, I don't think it is a good addition to stdlib because it is a hack to quickly mute a warning in an incomplete implementation. |
Hmm, good point, I don't know if that's possible, but only disabling it per source file. I think the warning is useful when it's a true positive, but often gfortran will throw spurious warnings (unused in this case, or uninitialized var in case of allocatable strings). But all I can say is, "I don't like it", but it's possible that it could be useful. So if others support it, I will too. |
This could be a good excuse to have a |
Agreed, opened an issue for further discussion at fortran-lang/stdlib#317. |
And use it in the high level version of read_formatted.