rfc:readline_interactive_shell_result_function
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:readline_interactive_shell_result_function [2020/12/20 21:56] – created tandre | rfc:readline_interactive_shell_result_function [2021/01/06 03:27] – tandre | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Configurable callback to dump results of expressions in `php -a` ====== | ====== PHP RFC: Configurable callback to dump results of expressions in `php -a` ====== | ||
* Version: 0.1 | * Version: 0.1 | ||
- | * Date: 2020-12-10 (use today' | + | * Date: 2020-12-19 |
* Author: Tyson Andre, tandre@php.net | * Author: Tyson Andre, tandre@php.net | ||
- | * Status: | + | * Status: |
* Implementation: | * Implementation: | ||
* First Published at: https:// | * First Published at: https:// | ||
Line 9: | Line 9: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Many other REPLs (Read-Eval-Print Loops) that I'm familiar with print a (possibly truncated) representation of the result of expressions, | + | Many REPLs (Read-Eval-Print Loops) |
It would be useful to allow users to extend the functionality of the default interactive php shell ('' | It would be useful to allow users to extend the functionality of the default interactive php shell ('' | ||
Prior to this RFC, there was no way to extend the interactive php shell in this way. | Prior to this RFC, there was no way to extend the interactive php shell in this way. | ||
(I've seen https:// | (I've seen https:// | ||
+ | |||
+ | Because PHP's interactive shell is written in C, adding new features or bug fixes would require a lot of time getting familiar with | ||
+ | C programming, | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Add a new function '' | + | Add a new function '' |
- | Using this, users can configure callables to be run every time a statement containing a single expression such as '' | + | Using this, users or applications |
<code php> | <code php> | ||
Line 35: | Line 38: | ||
Real implementations may be much more complex, and make use of parsers such as https:// | Real implementations may be much more complex, and make use of parsers such as https:// | ||
+ | |||
+ | This has the following signature: | ||
+ | <code php> | ||
+ | /** | ||
+ | * When $callback is a callback, replaces the old callback used to dump expression results. | ||
+ | * When $callback is null, removes the callback used to dump expression results. | ||
+ | * | ||
+ | * Currently, this always returns true, but future changes to the implementation | ||
+ | * may make it return false. | ||
+ | */ | ||
+ | function readline_interactive_shell_result_function(? | ||
+ | </ | ||
+ | |||
+ | A new system ini boolean setting '' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | None, only interactive sessions are affected, and only when this functionality is enabled. | + | None, only interactive sessions are affected, and only when this functionality is enabled |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 60: | Line 77: | ||
* In order to provide more extensive default handlers for tab completion and rendering of evaluated expressions, | * In order to provide more extensive default handlers for tab completion and rendering of evaluated expressions, | ||
+ | From https:// | ||
< | < | ||
Miscellaneous thoughts on implementation details: | Miscellaneous thoughts on implementation details: | ||
Line 68: | Line 86: | ||
Is packaging a parser practical for a '' | Is packaging a parser practical for a '' | ||
- | A parser may fail for code using new token types until the parser gets updated to handle the new token types. This stops being a concern after feature freezes. | + | * A parser may fail for code using new token types until the parser gets updated to handle the new token types. This stops being a concern after feature freezes. |
- | Looping over '' | + | |
- | + | | |
- | How would crash/bug fixes of phpi or the parser be handled in patch releases of php if this was released with php? | + | |
- | + | ||
- | Automatically rewriting the code to namespace the parser and its dependencies with '' | + | |
- | would let '' | + | |
- | + | ||
- | (clarifications may be necessary to indicate to end users that the bundled parser copy won't get updates or support outside of php minor releases, | + | |
- | should not be used by libraries/ | + | |
</ | </ | ||
Line 83: | Line 94: | ||
This was left out to simplify the implementation, | This was left out to simplify the implementation, | ||
- | (i.e. change '' | + | |
+ | * i.e. change '' | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
+ | |||
+ | Voting starts on 2021-01-03 and ends 2021-01-17. | ||
+ | |||
Yes/No, requiring 2/3 majority | Yes/No, requiring 2/3 majority | ||
Line 91: | Line 106: | ||
* https:// | * https:// | ||
+ | * https:// |
rfc/readline_interactive_shell_result_function.txt · Last modified: 2021/02/03 00:39 by tandre