Skip to content

Conversation

@Brijesh-Thakkar
Copy link

Adds a minimal Python-like input(prompt, stat) function to stdlib_io.
Reads a full line, optional prompt + optional stat, follows stdlib error semantics, no parsing.
Includes docs, tests, example, and CMake updates.
Small, safe, ergonomic addition aligned with stdlib goals.
Ready for review.

Copilot AI review requested due to automatic review settings December 8, 2025 20:04
Copy link
Contributor

Copilot AI left a 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() convenience function to stdlib_io for reading user input from standard input with an optional prompt. The implementation reuses the existing get_line_input_char infrastructure and follows the module's error handling patterns. The addition includes documentation, an example program, and basic compilation tests.

Key Changes

  • New input(prompt, stat) function that displays an optional prompt and reads a line from stdin
  • Example program demonstrating both simple usage and error handling with status checking
  • Documentation section describing the new function with syntax and usage examples

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/stdlib_io.fypp Adds input_character function implementation and interface, plus general whitespace cleanup throughout the file
test/io/test_input.f90 Adds basic compilation test for the new function
test/io/CMakeLists.txt Registers the new test in the build system
example/io/example_input.f90 Provides example demonstrating simple and error-checked usage
example/io/CMakeLists.txt Builds the example executable (not run as test due to interactive nature)
doc/specs/stdlib_io.md Documents the new function with status, description, syntax, and examples
.gitignore Adds .venv/ for Python virtual environment directories

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This commit adds a minimal Python-like input(prompt, iostat) convenience function to stdlib_io.

Files changed:
- src/stdlib_io.fypp: new generic interface and input_character implementation
- doc/specs/stdlib_io.md: documentation, Arguments and examples
- test/io/test_input.f90: compilation + CI-safe functional tests
- test/io/CMakeLists.txt: register input tests
- example/io/example_input.f90: example

Behavior:
- Optional prompt printed without newline
- Trailing whitespace preserved
- Optional iostat returns 0 on success, non-zero on EOF/I/O error
- If iostat not provided, follows stdlib error semantics and calls error_stop on error

This fixes Issue fortran-lang#259.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant