On Sun, Dec 20, 2020 at 11:36 PM tyson andre <tysonandre...@hotmail.com>
wrote:

> Hi internals,
>
> I've created a new RFC
> https://wiki.php.net/rfc/readline_interactive_shell_result_function
> adding a way to configure a callback to be called to dump the value of
> single-expression statements from `php -a`
> (and an ini setting that can be disabled to prevent that callback from
> being called).
>
> Many REPLs (Read-Eval-Print Loops) for other programming languages that
> I'm familiar with
> print a (possibly truncated) representation of the result of expressions,
> but PHP doesn't.
> It would be useful to allow users to extend the functionality of the
> default interactive php shell (php -a),
> possibly with auto_prepend_file or through use of command
> wrappers/aliases, or after loading the shell.
> Prior to this RFC, there was no way to extend the interactive php shell in
> this way.
> (I've seen https://github.com/bobthecow/psysh mentioned as an alternative
> for php -a while investigating this,
> but that's a shell written from scratch, and doesn't have some
> functionality from php -a such as tolerance of fatal errors)
>
> Because PHP's interactive shell is written in C, adding new features or
> bug fixes is inconvenient - it would require a lot
> of time getting familiar with C programming, PHP's internals and memory
> management,
> and with PHP's internal C ast representation.
> It would be easier and more accessible to extend PHP's interactive shell
> through code written in PHP rather than code written in C.
>
> This was among the proposed enhancements I brought up in
> https://externals.io/message/111073 .
> An earlier version of the implementation was also created months ago -
> https://github.com/php/php-src/pull/5962
>

Reading through the linked earlier mail, you have quite a few additional
hooks in mind, which might need a significant amount of additional userland
code (such as a parser implementation) to usefully implement. At that point
I'm wondering what the benefit of this hybrid approach is, relatively to a
userland implementation like psysh.

That is: a) Assuming all the hooks have been implemented, what additional
functionality is the interactive shell implementation itself actually
providing? b) Is it possible to go the other way around, and expose that
additional functionality to userland instead? You do mention fatal error
tolerance as one distinguishing feature -- is there anything beyond that?

Regards,
Nikita

Reply via email to