Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114919 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 21624 invoked from network); 17 Jun 2021 07:57:21 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jun 2021 07:57:21 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3EB0E1804D1 for ; Thu, 17 Jun 2021 01:14:16 -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 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 ; Thu, 17 Jun 2021 01:14:15 -0700 (PDT) Received: by mail-ej1-f41.google.com with SMTP id l1so8377152ejb.6 for ; Thu, 17 Jun 2021 01:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qvDhYCfRq+QytclVOeQ1pcrifYpM+r+nqeHP6YJLt4M=; b=udC4MHGRV+8JkxX5G3i/okPfdyoZZEdRoKh3NVWxUwGdqoZx86NL4Sy5+0P311PRMl W/drngXfm83D7Tg8OHdQ9jXsS/z+Z6V7LcOA2RYtzfwWNeSRpxLE1cTQMRzxpYIkGV4R G67xKEzoirt9CzJoYkKJAIE0CIMmlUHcx5Q6uDOVw7TeeOfLUV14WEYQsVrPN1ce+deX eQZu6KVYQsfeMk9g5QwH0rtOCkpU6fvHDrK45pXSlvKVM9RPN6h2e/8OjrY+b26ROJtb qmmskkl4B2gAsZarx5h/p1PMaYgCXkcq94smVHLFPXyo9PA9rBPvvAJUknJ6D3mjYPZX uulw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qvDhYCfRq+QytclVOeQ1pcrifYpM+r+nqeHP6YJLt4M=; b=m1Z2VrnL1c7H/trleMEP/amwwWHq94AMAd9JREwkWLobo04JpjizEjWYjIGztuaHUv btva1JE/Zi2J4EhPtDuPkRMGnqdKiyXXfcK9i+nr0kGpOxN/vLGVeglrmtALVBB2rRWs nUj0JTnvcm1i+wVF/9Z6Uy9/cX6gaPrSlerpQ/vSCYJ15BvASj0wtLEhsk5qPoNemPZA ilTW1R0t/k51aSNUOkN/7mPhB4n7IBQVJpSZuk9rfHcoJdH5bg2BAbFH/0H28MCxkwtZ bbuvYnhFTACj9dmAKO5HBsymfNiq8qkfR7TnvJ5al/vzzozK6Otj4b+9YrvNh0WMJ5v9 Sqxw== X-Gm-Message-State: AOAM533qyt/cI7zKGTbRXqiAQR9s6JXP4aImPJuKqNRwHfRIx0ZwUYdH H9OFpVAoj3kjbEyCLIYmvlgVNkfdj4bPac559O9VCuxROKcLkw== X-Google-Smtp-Source: ABdhPJzdXaS9AG9ydG8d6JIWEitOq1S0vI1uND23Y3vZ8MNCdBWVYM7lzoEcvn8MWs23oSQ8erQ7dZRL5PuGyMf2RGw= X-Received: by 2002:a17:907:9047:: with SMTP id az7mr3982490ejc.4.1623917651374; Thu, 17 Jun 2021 01:14:11 -0700 (PDT) MIME-Version: 1.0 References: <88588b8f-5729-4458-90b1-c602f751e128@www.fastmail.com> <33fd3541-8518-4f98-a258-705f85180ed1@www.fastmail.com> In-Reply-To: Date: Thu, 17 Jun 2021 11:13:54 +0300 Message-ID: To: Nikita Popov Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000c136ac05c4f1caae" Subject: Re: [PHP-DEV] [RFC] New in initializers From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000c136ac05c4f1caae Content-Type: text/plain; charset="UTF-8" On Wed, Jun 16, 2021 at 11:17 AM Nikita Popov wrote: > > > The options where static properties and class constants are concerned are: > > 1. Eagerly evaluate initializers on declaration. This is what I tried in an > earlier revision of the RFC, and I don't think that approach works. It > breaks existing code and has various other unpleasant complications. > 2. Precisely specify the current behavior. I don't want to do this either, > because the exact places where evaluation happens are something of an > implementation detail. If in the future we find it convenient to separate > evaluation of non-static properties on object instantiation from evaluation > of static properties and class constants (which are not strictly needed at > that point), I'd like to retain the liberty to make such a change. > 3. Do not specify an evaluation order, beyond that evaluation happens at > certain uses of the class. Evaluation order may change across PHP versions. > If your code relies on any particular order, your code is broken. > > Unless I'm missing a fourth option here, option 3 is the only one I would > be willing to go for at this time. > I think I was one of the people that came up on the mailing list with the idea that it would be good to have the order of evaluating the initializers clarified in the specifications. Little did I know at that time how constants are "evaluated" until now. I watched the topic and comments you added few months ago on the PR while you were doing the implementation and got into trouble with preloading that really can't work nicely with eager initialization. I didn't say anything at that point but my ideas went towards option 3 as well, specifying that the evaluation order is not well determined and can change in the future so I agree with others here. It's not the first time this happens in PHP (https://3v4l.org/fQhgB) and I think we will be fine with it. Alex --000000000000c136ac05c4f1caae--