Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112975 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70242 invoked from network); 24 Jan 2021 22:00:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Jan 2021 22:00:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DD4B71804A7 for ; Sun, 24 Jan 2021 13:41:11 -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-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 ; Sun, 24 Jan 2021 13:41:11 -0800 (PST) Received: by mail-wr1-f52.google.com with SMTP id m1so9665100wrq.12 for ; Sun, 24 Jan 2021 13:41:11 -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=b1w/UyLPb337QVZ4ZJLEy3xqR9sUhFPrCZsvgzXHXYo=; b=AXVHRZT+j3uWKdPXWTNnmkiBsHIPTeXXjK9ODBOSbc1VGGRIa3bVhmvO+7VbGNNq6y HzUZya0l5dkCzm3r9jaWIuLuVO+/9wZBFumLUYS1S+yLsJBLM1kexI7WRZQ1GzUvYGqr TkgPOeXiA1wZp7c88R3sutUect7S6uqwHw+mPSdTWKGzBpRvzaHdcEcBenFqfzDg18yn vfUama36WEKfxMnsQVCU2niAGgrIW2T1H3Sy/qVqzi0HyXIJXm/EF7K2DCYGgjST18sE xgCOPeLtDlDLLM14Eroscuy09rEHB+ZKyXZSdehh3+dew6AsVYXZbU25T0OP8VBrOCJI DIFw== 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=b1w/UyLPb337QVZ4ZJLEy3xqR9sUhFPrCZsvgzXHXYo=; b=syQ6O/TMHCPRBbYPJh53gWyaeJqLOsU5BsU3hq4DE02oklZNyaCIogz5jr2TOjsiP9 l5yUtVHaYBgNrIAEon9T2n1mjHAU8jjAxFwNDbC9lAVEtukiEMnLQwy7qt+r9cIZj9hD U4bQMcFAuJlTyV4+3gDaEtDQswWeRAVIA6ETVtnFmiAK5+5/7ouNpZb4Dt2Dn51wGbGp NWqGk96oLwsxxupriL51MGzkKyl9r7M5ck28m7Urg0x9kVjJ/aWfYU4aWHoRyCRozAPD GpFBi4/olDNih4rIFDxTIUH7/W/9VWWYa0YENBCwqjtoW67f7nxNkd0AvVyP8m3ECuI+ WpqQ== X-Gm-Message-State: AOAM533JouGTgzhshb+wnYvdWmXzCgHlpCjQ34GUTIt90xq/3vKHi6BL h26DrzUgJj5tIah5RZpD4U27xnYuADo= X-Google-Smtp-Source: ABdhPJz43T8O2EYU5UGod2veVwu8xGhlo8whVOBPh8YltPGT9eWe2RXcAT0av1iYRZAAdBuIJ8JAnA== X-Received: by 2002:a5d:58fa:: with SMTP id f26mr14620332wrd.33.1611524468926; Sun, 24 Jan 2021 13:41:08 -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 s25sm22067843wrs.49.2021.01.24.13.41.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 24 Jan 2021 13:41:08 -0800 (PST) To: "internals@lists.php.net" References: <5ae166a8-378e-b3bc-056a-8ccf4f3a1ddd@gmail.com> <8e5d376c-0d7d-bf1b-bcca-3f8c4c737a22@gmail.com> Message-ID: Date: Sun, 24 Jan 2021 21:41:06 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 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] var_representation() : readable alternative to var_export() From: rowan.collins@gmail.com (Rowan Tommins) On 24/01/2021 19:38, tyson andre wrote: > If a php developer is learning the language through php's official manual, official language reference, or through an online tutorial, > that would have sections showing the different scalar types, examples involving objects and/or arrays, etc. > Those use var_export/var_dump > > https://www.php.net/manual/en/functions.anonymous.php > https://www.php.net/manual/en/language.types.string.php > https://www.php.net/manual/en/language.types.boolean.php > https://www.php.net/manual/en/language.types.object.php Every single one of those uses var_dump, and I see no reason why they should use anything different. > The use case of "generate a (short, readable, escaped) representation of a variable that can be evaluated" > is something I'd consider useful enough on its own, a useful primitive in a modern programming language I guess I just don't agree. I think the use case of "generate a representation that can be evaluated" is adequately covered by var_export, the "short" is mostly irrelevant, and the "readable" mostly opinion-based. The "escaped" sounds useful, but more as an enhancement to the current function (with a flag, if compatibility is really an issue) than a ground-up re-design. > Imagining that var_export was never added to the language with those arbitrary formatting decisions > in PHP 4.2.0 and an RFC was being discussed to add the **first** built-in way to convert a string to a machine-readable language in PHP 8.1: > Would we really choose the indentation var_export used? > Would we advocate putting values on different lines from keys being aware of common coding standards? > Would we use `array (` with a space instead of `[`? No, I agree with all of those things, if PHP had no such function right now. But it does, and the changes don't seem significant enough to me to bother duplicating it. > I would be in favor of adding string escaping to var_dump, > but that is a discussion that should be "left out of this" RFC > as var_dump has a different purpose. Sorry, I'm really confused here. On the one hand, most of your examples are of things that currently use var_dump; on the other hand, you insist that improving var_dump is a completely unrelated topic. Surely if var_dump was improved, that would influence the choice of function in those use cases? Regards, -- Rowan Tommins [IMSoP]