Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117829 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84201 invoked from network); 29 May 2022 18:04:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 May 2022 18:04:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DD1CE18037E for ; Sun, 29 May 2022 12:48:17 -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, 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-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 29 May 2022 12:48:17 -0700 (PDT) Received: by mail-il1-f174.google.com with SMTP id 3so6382874ily.2 for ; Sun, 29 May 2022 12:48:17 -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 :content-transfer-encoding; bh=NPE5X4XftIQ05IW6CpsRfeC2d6RkjY+6LIQwI2gDO4o=; b=eVt/zkXziaahZlcTE26W/qmWTLss0gyu1HhSChbU5NwHD84VCXAPbPzvkH8WsqzCyx EBybkxHrtrXyngxMXJEVLB+GQNaFVwRleVsa1i0cJTWQcRPhtOgdjL6Bi6Og37x9FT5+ sOjjtB/a/Ed4OPJ1EFiSZpgtV98L2T/1ElBY/+kq2F0Gxa8sv0odth3pUw7QmkCiVA+y Z860+kxE6cv9CkWo3PDUfVcyfZex5tZjM7lc/0Dal66EHSQ+UGtHLVs+uU5EbiV7xBoE nZU0Q9TDGIYYWGldWVdDSMx1YjhqiJqWBmWdQn8FmfHhYiamHGXVmNtxMGosjXYg9HTG 2RWg== 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:content-transfer-encoding; bh=NPE5X4XftIQ05IW6CpsRfeC2d6RkjY+6LIQwI2gDO4o=; b=Z46eBPhrYDK0XYBHrnBMmv0wO4zBVUL5MXEwdyGRiasKwig0uEa4WbEBdKCapRhw9I cLyIb0qCr0Sv4ol+248xXkhctP4q4wiFDzL/Wo9SJIhJSnbUq3xlktzuoOnqfxEieCNg sHEOi+MAjZAYKXKtSIBmrjezImfbHPqYwID1O/QePOF52bk2blWWTDi4SlilKFWAe2Ah zlwJV6IcNGqPO5h/6uqkHSslnwq2gkFaCaNeUMNQoIr0CQLWVzZHInBUJIy9rU87k3y7 QCiX2AvZnJu2lbjINwsfhjbIp8eKADfu+nF/cbooIT9jkKK0fJW9wqbfi4g/nOv3n4s1 wHIA== X-Gm-Message-State: AOAM532Lm68I9hvQTnyKg+f1LUS5uZ6DL/A1THvpnPZ45OMajr2W749h Kvsif9xP/gt0IvMAfUkQhTtmeUHSP3N91x+BaaIzgo09sPAfgA== X-Google-Smtp-Source: ABdhPJyXT3dBCCDiOxSQMaiWAWEzqfw2214PjE3f/+cUA67dIHcjdJ+BWbTwKP2Bz9ICmx2iqKnm4LFcMZTpZSz1EDc= X-Received: by 2002:a92:c544:0:b0:2d3:9998:174a with SMTP id a4-20020a92c544000000b002d39998174amr3038643ilj.257.1653853696649; Sun, 29 May 2022 12:48:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 29 May 2022 21:48:05 +0200 Message-ID: To: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Under discussion] Fetch properties in const expressions From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Micha=C5=82 > Personally, I'd start the discussion on > https://wiki.php.net/rfc/object_keys_in_arrays instead as this might solv= e > the need for > fetching property in constant expressions. As mentioned in the RFC, supporting objects as array keys requires much larger changes in the engine, and also breaks userland assumptions that array keys can only be of type int|string which means array functions need to handle object keys accordingly. For comparison, the "object keys in arrays" RFC is incomplete (changes for most extensions are missing) and contains ~1300 LOC added and ~1300 removed. All 3rd party PHP extensions would also need to be updated accordingly. The implementation for this RFC is feature complete and is at ~160 LOC added. I actually think both of these RFCs are worthwhile, but since this one is simpler and does not break userland assumptions it might solve the problem in a good enough way. --- HI Alexandru > I feel that the RFC should be named "Fetch properties in initializers", i= n sync with https://wiki.php.net/rfc/new_in_initializers > You explain what "constant expression" means but I feel that using "initi= alize expression" would be more clear. > From what I understand, "constant expression" is named like this because = until PHP 8.1 it really was a constant. > And of course because internally this is how the functions in code are na= med: > - zend_is_allowed_in_const_expr > - zend_compile_const_expr > - zend_const_expr_to_zval > > It's unclear how easy it would be to rename them to init_expr instead of = const_expr > but it might be worth it if we consider that "initialize expression" is a= better name. Note that we also use the term constant expression in some error messages. https://3v4l.org/d2WnS I intentionally picked a static variable to show that it's not restricted to consts. But I'm not attached to the term, if it's clearer for other people I'm happy to switch to "initializer". Regards, Ilija