Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117389 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49972 invoked from network); 21 Mar 2022 09:01:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Mar 2022 09:01:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6C89F18037E for ; Mon, 21 Mar 2022 03:28:09 -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,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 03:28:08 -0700 (PDT) Received: by mail-pg1-f178.google.com with SMTP id s72so7283425pgc.5 for ; Mon, 21 Mar 2022 03:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tvmidw8LONTxZ7YRx9fNd4O3Pp8qw7gNAUpRmxnoLYo=; b=MGkMhtoQipMjapYJJKMsGP1eUwr/3EaCVLOA6nmfGCWPUMj41AcLigAJ2BTYhxopu+ kpL+ilo+Gg+FMbE6rYej7Si/QoOdKo7KvF2kgjwFrO6rX640TbF240GpYigzTqhf6QUj nAm9nVbmPQb+PoCLSBBXzzBanG3M9tuypdFXd6mMW1WXlzeHUzIsXso9pvRvSVjjI/6j Cs/PCVdheX4AVLPoZBkiPsDLe+qW6MwTgUQjqQtGBuyQy3Bjscp5X81wTSNyUNSrLVfH iWmOjwbIPgy64QAZ6eMh4qUNJfrvjDRekb5XC+y8SZZdc40YjwWVkgdqjtBSmsyqZiZj BiZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tvmidw8LONTxZ7YRx9fNd4O3Pp8qw7gNAUpRmxnoLYo=; b=diz0yrq0CMwlTMNlGTRVBcWVciC3IJuFQ8OAMibkjBS8YWQQJ5dXKYfzHBu+mOn8RV 35/a5jGgcTwe8utu2TsFuxKXFx9K5X7ON79gIatCCiP9HULSF+s6JBCAz9ngGD8qne3e Op2esNekQNcnwnWRZ2w2nIhczmLSl7xf18bPPbo4Gy9uzvXbBnDX7mrYFZSXDKASa1p1 /434KUBXHZXeYL426gIzyZrSfkH/K4WkdH0kmP8pN/UwqCuceU/hasGAv6NjFORf90Y+ C11NigbfZ8YktZiUWUpEFMHK2LQbPVzcH3vWxcvn70FHcfn+SJgL4BVz4CLa945G35kZ Pp+g== X-Gm-Message-State: AOAM53255op9Bcj3Z0btcH35N+ds8O/KOyE5NJRjzfyUHHN94jj/RMx0 w9fityLnGMBoFNT+BERBOMjYQzJkysRO8VZGO8U= X-Google-Smtp-Source: ABdhPJwppx/vsDsnEF3J+ubUCBra61URJF7576oV9huzA2nRetx/Hb1g3FcUrKVTLuiX8a7Zsuik3n2zkogjzYCwUQo= X-Received: by 2002:a05:6a00:ad2:b0:4f1:2734:a3d9 with SMTP id c18-20020a056a000ad200b004f12734a3d9mr23389289pfl.61.1647858487738; Mon, 21 Mar 2022 03:28:07 -0700 (PDT) MIME-Version: 1.0 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: Date: Mon, 21 Mar 2022 11:27:56 +0100 Message-ID: To: Rowan Tommins Cc: internals Content-Type: multipart/alternative; boundary="000000000000cd455005dab7f38d" Subject: Re: [PHP-DEV] [RFC][Under discussion] Arbitrary string interpolation From: landers.robert@gmail.com (Robert Landers) --000000000000cd455005dab7f38d Content-Type: text/plain; charset="UTF-8" On Mon, Mar 21, 2022 at 10:51 AM Rowan Tommins wrote: > On 20/03/2022 13:39, Rowan Tommins wrote: > > Using a second colon would make ternary expressions slightly awkward; > > C# handles this by requiring them to be parenthesised, so "{$:( $test > > ? $x : $y )}" would be valid but "{$:$test ? $x : $y}" would not; we > > could use some other delimiter, but they'd probably all need something > > similar. > > > Thinking about it, a second colon might also cause problems for > expressions like "{$: Foo::bar() }", so since we have multiple symbols > at the start anyway, how about a prefixed formatting argument, e.g. > "{$%10.3f: $x }" > > Regards, > > -- > Rowan Tommins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > 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 }"; It isn't pretty, but it's better than a parse error and things like Rector could do this automatically. --000000000000cd455005dab7f38d--