Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112763 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16637 invoked from network); 5 Jan 2021 14:03:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jan 2021 14:03:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 280741804E4 for ; Tue, 5 Jan 2021 05:39:43 -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, 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-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 ; Tue, 5 Jan 2021 05:39:42 -0800 (PST) Received: by mail-wm1-f53.google.com with SMTP id g185so3087775wmf.3 for ; Tue, 05 Jan 2021 05:39:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=YyRiw2R1PKfqecihJyBso/R3iy8eSTapCGZu2A8Pme8=; b=P2AtAEZl1U4QrJcdRGRHQLn969e5OPC2iOShEfXjP3YsM5o5oXCSDoIw/fsiUDc73H hKVRiBFBf1GMU/8e+mNKD1jnb/C7YbnvEGbFIDQpFK4mcanyxDl20TzhdfUEjuUteoCc LRloO7uc4DrzlB2y2plVk2+M3nZYwMNlsJE8ueMulQQ6qhuVIMyqiiWG+5C0He3MdmQV OIFAyaKgqD6odhCkWZbAfzVowab6PafSXFDcLKm7gBvBdfGTiQryTJqjDzEjSa93d53b vbkOjPp3/bsiqztcP5D/HP0+CVf3QUOGKSF5/v6j9gvFOrphf60m97MNF7RzJ7kvbSDg kwIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=YyRiw2R1PKfqecihJyBso/R3iy8eSTapCGZu2A8Pme8=; b=BBVR4y3w5roo+vjgip3tiVupQYIYJJRc+MylBDvb2SnVtUJmK9sxMJTtxoZBMBJBok m0WcYdqQGqZZkG7phwdNWuvkXv3ycAgNp5H6pwVMJW8PteYwkO0DA7RUdehKDIP+KldB FmwGv1lytOsCEORELGY4c8NigbMOAtDSOIw6qPsfl57cL/mJXFmO5MtAFGXyTL4riYDo VrXWnncKMzlhbvL++8+MuYBYgT5fyYnmEZcwNcz2Seq+bbS/lBLUZiTLaAHrPWL0eVC8 SJ7PlwOsOyjs7DusZ457i7wx349El/pH9NcZmpQcHkqqn6wRdj60lHvyO8nN4QuLn8Ts D2DQ== X-Gm-Message-State: AOAM533h/BQrRhq0Btg+a5EdTc9p7BDjNn+Vt+rqem9r7jdsGzGBO0AY V9WPPg3bUfql8S7gVXgOpK0S2A3SStaYlg== X-Google-Smtp-Source: ABdhPJzb9VH/Aw+WGTOoCamp2yzbQSkWzvwm7pm451LbloASy56Y0EcCUYedsrYb7cmauKJo7p5Myg== X-Received: by 2002:a7b:c145:: with SMTP id z5mr3512694wmi.164.1609853979487; Tue, 05 Jan 2021 05:39:39 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id w17sm4392435wmk.12.2021.01.05.05.39.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Jan 2021 05:39:38 -0800 (PST) To: "internals@lists.php.net" References: Message-ID: Date: Tue, 5 Jan 2021 13:39:36 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Configurable callback to dump results of expressions in `php -a` From: rowan.collins@gmail.com (Rowan Tommins) On 03/01/2021 20:45, tyson andre wrote: > __debugInfo() is a slight improvement, but the human-readable representation of an object isn't always the same thing as the debug representation of the object. > A human-readable representation might be `Point(x: 1, y: 2)`, where var_dump or var_export(`__set_state`) > is much longer, and I don't believe var_dump is a one size fits all solution for both simple and recursive data structures, > especially since `__debugInfo` predates the repl. A couple of notes on this: - The readline-based shell for "php -a" was added in PHP 5.1 [https://www.php.net/manual/en/features.commandline.interactive.php] and __debugInfo not until 5.6 [https://wiki.php.net/rfc/debug-info] - I agree that the existing debug outputs are quite verbose, but I don't think that's a problem unique to the REPL. var_export() is constrained to render valid PHP code, but print_r() and var_dump() could and perhaps should represent objects more compactly. - That compact representation of a Point would be useful pretty much everywhere anyone wanted debug output. It would also be possible to build it on top of the existing functionality (key-value pairs from __debugInfo if defined, else all properties). - Allowing objects to overload the output seems much preferable to the formatting function having to know all the special cases, so I'm not convinced of the need to hook the entire output for the shell. - I can't find any references off-hand, but I'm pretty sure popular REPLs in other languages take that approach: use existing pretty-printing mechanisms from the language, which in turn can be overloaded by individual types / classes. Regards, -- Rowan Tommins [IMSoP]