Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add format_string routine to format other types to strings #444
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
Add format_string routine to format other types to strings #444
Changes from 1 commit
e3829b4
da2881c
c622a5b
193f07f
7f6c3c6
41c5783
785902c
39d5d13
99954bb
f9f7755
e7ce1e7
65ab05d
34fa3cd
7ae89fb
1fe6a07
f155525
f1bc676
835de22
b05cbae
e646fc5
c717724
7fa847a
bdc33f5
f3c17a0
ce272d7
527daed
32f9837
3e31220
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a meaningful number of asterisks in the output we must be able to parse format strings and determine the width of the field we are writing into. Just writing a single asterisk until we are able to do so in stdlib sounds like a good compromise for now. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is OK, just writing a single asterisk until we are able to do so in
stdlib
.😜There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
*
sign here should be distinguished a little bit more, for example, written as[*]
,!*!
and the like can be distinguished from the*****
sign (too narrow formatter for variables) before and after it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking a failed formatter should be simple, currently I'm using
starts_with(format_string(var, "(...)"), "*")
. This is not fail-safe as it would match a formatter like'("*", g0)'
as well. Usingformat_string
should imply that we trade some of the versatility of the internal IO approach for having a function.How about returning an empty string on failure? This would be clearly distinct from a too narrow formatter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is mainly to remind the users: an empty string may not be effectively fed back to the user, this is a
format_string
failure.Fortran
program.