Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112719 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16259 invoked from network); 2 Jan 2021 23:42:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Jan 2021 23:42:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BBEAB1804C6 for ; Sat, 2 Jan 2021 15:17:57 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 2 Jan 2021 15:17:56 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id m25so56018326lfc.11 for ; Sat, 02 Jan 2021 15:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SKrIRK/8ezHMRgiwzGrY0OW77x9J7P61Iq+zEJlic6g=; b=dwxdgEROVO0fd1x1w227g2xYqs6pk7FgJU6dlu+JPzyc7jC/XFtfNlQx6TMjzNaDep ojqboyH+99oMUk3Sv4Ucan1rEQYio/0CerwJu+tmmIryTJzHxAK42+ed9NR/mYjuGM10 nRRLBO2WZuuOwA1XkZ5CzgTyK7gobsofJDwL+9QVskWCiFgdHhHJp6Cudrp1FlNPoIqb PSfAMoThEBHuxYR4roqqW1pj0bxlGfkBnLe/llXzTyRdPAy4hxg3VGtTNxravpyNKv5/ tEFF2+ltS3tAxYlRbdMehu+kwN29Xrr/6Kf4KBTbo9E/SvAQqKRU2qPK6TDVOlhP40HQ sq1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SKrIRK/8ezHMRgiwzGrY0OW77x9J7P61Iq+zEJlic6g=; b=BW/Qa/YAIzn+WSBJUbQ60cYl6ueWQrx/Ah1F4YArlMlCWkb7B+rDIj01D8oxK7B2qT SstjDKeESDlGWcFSw7p9CMUXuXJZpsgCu0tZZmji5Nj3Juab88CJ4ekzPI+5BqK5/0F2 A2HMRNOoJ/s78AxeIINRcPeQSu0uQGGlKtyFYo3sj/HPuGha9eUutmEMSydwrNwfCmxH KlhUqsGz3sBnBl4Gh5pvcf5QltYsm6+nymjTC26ipZSrn7o1cR1oczj5NGuNi9aJkglE JpAOn6y5x25pG1NAZTBEIel6ijlNE3fP39A+Xd5+AuDdgRl/05fzSc7t8vc7PNT1iKhd i3fg== X-Gm-Message-State: AOAM531+HPcYA/cy0wN8cwq/p35Eg9YFhF+dfh/YXwSdpHW0W044b1iu ySaoXqDLIjOEjMJY6h7bHXkUNMox5qWlQuuvLuk= X-Google-Smtp-Source: ABdhPJxkDUyczT2Q6c+C5z1s+wezHEvuR2xnV05u+b3W7ImhP8TW4Tfl8slbeuhBd2YeChkC4T9QUbRD83fWd0FhS6w= X-Received: by 2002:a19:ed6:: with SMTP id 205mr31202715lfo.159.1609629472925; Sat, 02 Jan 2021 15:17:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 3 Jan 2021 00:17:36 +0100 Message-ID: To: tyson andre Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary="000000000000f42d0005b7f310bc" Subject: Re: [PHP-DEV] [RFC] Configurable callback to dump results of expressions in `php -a` From: nikita.ppv@gmail.com (Nikita Popov) --000000000000f42d0005b7f310bc Content-Type: text/plain; charset="UTF-8" On Sun, Dec 20, 2020 at 11:36 PM tyson andre 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 --000000000000f42d0005b7f310bc--