Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117390 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56877 invoked from network); 21 Mar 2022 10:56:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Mar 2022 10:56:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 582011804AF for ; Mon, 21 Mar 2022 05:23:11 -0700 (PDT) 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,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 ; Mon, 21 Mar 2022 05:23:10 -0700 (PDT) Received: by mail-wr1-f46.google.com with SMTP id a1so19066167wrh.10 for ; Mon, 21 Mar 2022 05:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=jOG7sHcodtoPxJhdZcgVibu3mKd2reYy5sePrpLkCyI=; b=Kt7dqtwOOAvA4CeuAFW0J8iZgvLFvXKWzc33Vy6FqXwLw08KrdrerN69IEYN/b30d3 BNh8JY6OQ0xODdStNfoX6i6HEkuTuxPlrtuhWe/3e3A8lFbSNxT7/ZhfKzgeNp0R/RgO 2W/bROaMas6w0RwQFuJkVogWYGvaPI2JZ3kujmgAlke2Y6x3NX5mlusTUxx+StKA5HiF r5gDyx6NJ1gO8OhZqlQJYe8RgbeSV4sgWFoFvYV69VBJ/bHtcw68QxDJmjsgknHflm0/ w6jtAggztooB0ltWzndNTiXMWeFNvKh12DYyyDEKffiUucuO5ZX5jSHfefqskY+nPC0e QVNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=jOG7sHcodtoPxJhdZcgVibu3mKd2reYy5sePrpLkCyI=; b=aJxo4bDIjdGqoVPM23MYpC2CPwUNZ6zfvLPLWJWaT3tsV39zKQsdlMMBSpH9F9wr4Y DeXvep614Pcibj+bw5f+pN8KFliSLe1WKB0czup3/EIxC70sAaeEz7VxCORQjTIoAy0F Hoovz9rw9eDBxZpdCLYtJXWWEp14fhG2LXOYZTuosxuZMmCocFv/TVaYDvpzEY4Gnc0t HObzv3JTAsgz43WCAfHtP4uiQIb2iyeIyYQkROR5fnr3KbaklCHOpbU4vFdk53xsgygm 2GWUsODc8yLPKe2PoyyE7yBexxg/JdUSO/dYkXMIw6lUnmoeeSMiFaCjcvVU+pDPmosZ YvCw== X-Gm-Message-State: AOAM532FnoOiBgZi4wwVZvC5vMYCzGStkNIXnfS79vgWExvYhNGN5YXt lZi/o/Um26eRQ8J3aLd4A1rvlu4oJPU= X-Google-Smtp-Source: ABdhPJymj6c4/7ZxWKXKYvKqayoZr3fB0WhWuKxnwektXdKfaMz4brtmBSfpC78maHfuvXaUVeshRw== X-Received: by 2002:a5d:58d6:0:b0:203:de3f:e648 with SMTP id o22-20020a5d58d6000000b00203de3fe648mr18184746wrf.292.1647865389672; Mon, 21 Mar 2022 05:23:09 -0700 (PDT) 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 i35-20020adf90a6000000b00203e767a1d2sm11466153wri.103.2022.03.21.05.23.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Mar 2022 05:23:09 -0700 (PDT) Message-ID: <4ea1bcec-a85b-5e95-9ec6-d5ee68cf6602@gmail.com> Date: Mon, 21 Mar 2022 12:23:08 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-GB To: internals References: <4AC60E84-B2AD-43F4-9B72-92604FC7BD41@gmail.com> <73550eae-370d-115f-e440-4889e42dbc74@processus.org> <244126ae-f42c-3b53-022e-e69e3e012ded@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Under discussion] Arbitrary string interpolation From: rowan.collins@gmail.com (Rowan Tommins) On 21/03/2022 10:27, Robert Landers wrote: > The downside of a prefix is that it isn't backwards compatible. You could use # in a suffix so if you need to write backwards compatible code, you can. So maybe: > > echo "{$x#10.3f}"; > > which can be written like this in backwards compatible code: > > echo "{$x#10.3f > }"; That's a neat trick, although I'm surprised comments are allowed in that position given expressions in general aren't. I think being a syntax error in previous versions is a good thing though; falling back to ignoring the formatting specifier could result in unexpected behaviour, maybe even leaking data that the formatting was intended to hide, and projects which need to support multiple PHP versions are more likely to simply use sprintf() to get the same output on all versions. I was also deliberately pairing it with the arbitrary expression syntax as one new feature, so that we don't have so many combinations to explain to new users ("$x", "{$x}", "{$: $x}", "{$x#10.3f}", "{$: $x #10.3f}") Regards, -- Rowan Tommins [IMSoP]