-
Notifications
You must be signed in to change notification settings - Fork 208
stdlib_io: add Python-like input() function #1070
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
base: master
Are you sure you want to change the base?
stdlib_io: add Python-like input() function #1070
Conversation
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.
Pull request overview
This PR adds a Python-like input() function to stdlib_io, providing a convenient way to read user input from standard input with an optional prompt. The implementation leverages the existing get_line infrastructure and follows similar patterns to other I/O functions in the module.
Key Changes
- New
input()function that reads a line from standard input with optional prompt support - Preserves trailing whitespace and returns an allocatable character string
- Includes optional error handling via
iostatandiomsgparameters
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/stdlib_io.fypp | Adds the input_char function implementation and input interface, exports it in the public API |
| doc/specs/stdlib_io.md | Adds comprehensive documentation for the new input function including syntax, arguments, return value, and usage notes |
| example/io/example_input.f90 | Provides a basic usage example of the input() function |
| test/io/test_input.f90 | Adds a test case for the input() function to verify whitespace preservation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@jvdp1 Heyy, Please review this pr |
|
I will check why this one check is faling and commit the changes |
|
@jvdp1 |
jvdp1
left a comment
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.
Thank you @Brijesh-Thakkar for this PR. Here are some comments.
src/stdlib_io.fypp
Outdated
| !! - Preserves trailing whitespace | ||
| !! - Returns allocatable character string | ||
| !! - Does not perform type conversion | ||
| !! - Does not stop on error unless caller chooses to |
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.
What do you mean with this?
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 clarified this to explicitly describe the behavior in terms of iostat/iomsg handling instead of using a vague statemen
|
@jvdp1 Thanks for the comments, I will work on them and let you know |
|
@jvdp1 |
This PR adds a Python-like input() function to stdlib_io.
Features:
Documentation, examples, and tests are included.
All CMake and ctest checks pass locally.
Fixes #259