Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113405 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90342 invoked from network); 6 Mar 2021 13:37:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Mar 2021 13:37:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5FFB51804DD for ; Sat, 6 Mar 2021 05:28:40 -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,NICE_REPLY_A, 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-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 ; Sat, 6 Mar 2021 05:28:39 -0800 (PST) Received: by mail-wr1-f43.google.com with SMTP id l11so2156496wrp.7 for ; Sat, 06 Mar 2021 05:28:39 -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=g/eYppUUpGbY9mIlTSmIZ/I5gTovm12bmiuwc8vgYWo=; b=XOn+3Sp2mjTTSx3pK9Y+uhrx2glG9+KoDZ/86FfyHNbpQouyIinkNmdeqIM2y5h8T/ nmgfRZFFymjSsX9fKSE39OrtSLeiEWqJ/3VQtTlZ+pjf9h2Ofdqa8zS9dVNWc5QYuMVD 5W5GfnCDHL1GT0TBJTpj1GtDKSlu6svQEsNx2ShDwBGMv+Q3JbeQ8TrGxDt56+6v1PDJ 49AU8FdoPblX6u4GK/QPQ/K7kSkjpyf68ibGA4YKU+L9W7ZqCqnvVXoOCV2NZnE+SHaK 5b4xBE+gRIXvt+w2il2dpMxortAIeU1KowRNz8KGUlqxB0HtZZGcCgxAe9KkGrqQpnmy eBTQ== 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=g/eYppUUpGbY9mIlTSmIZ/I5gTovm12bmiuwc8vgYWo=; b=EVr0k+vchTGUHRLAnfd+abH6nCXgcKnwZz/MBAe4CyH9p3T2aAoHpo3aKNKkPbBU9V kxqT1y1JrPvjnuXhEYuxacup/VH3IqjZhAVqP+OPemDmnG0paUi+XUWWuiAOkhIJf4ax SwgF/05wHDXvfkOJtC8CAESAOpybG3mrPEZqH8LA7MGb7Vl3zZ1g+G5rkJXUT+yCHeGl 73hs7PNSesUuFOM9c4eNIVRX4DzYdB2V4ISr/nZWz4MFHVVmug6brWbXlyYf6IBCOFGK guiNq4+AoFmb3OPeMKMFtEiztp+Mx8N9xyqARmW/GhQU8s+ss4x3BbeJndCHf8B1KQut GE/g== X-Gm-Message-State: AOAM531662Ug30VBI9kRrhH0cEGovUgLDXZg2JGRfZHXsjub9DufLd6i 5FwjQZ00jJ03uT/EneHbM/8MVtfhdbE= X-Google-Smtp-Source: ABdhPJy62fCXEiNxEMS/HIlGiKcYebAg9sJQtOgELHmROpvPfwNh7Z7URhw+gy89dZbcFz13GbGzaA== X-Received: by 2002:adf:f083:: with SMTP id n3mr13846540wro.134.1615037318523; Sat, 06 Mar 2021 05:28:38 -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 o20sm9026678wmq.5.2021.03.06.05.28.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Mar 2021 05:28:37 -0800 (PST) To: internals@lists.php.net References: <60437107.1c69fb81.c3486.ac89SMTPIN_ADDED_MISSING@mx.google.com> Message-ID: <5fe3212f-e48e-9d17-1851-19a8855fcc6d@gmail.com> Date: Sat, 6 Mar 2021 13:28:34 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <60437107.1c69fb81.c3486.ac89SMTPIN_ADDED_MISSING@mx.google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] Re: [RFC] New in initializers From: rowan.collins@gmail.com (Rowan Tommins) On 06/03/2021 12:09, Andrea Faulds wrote: > This seems reasonable, but I fear it would create a similar mess to > C++ with static initialisers, because a class constructor can do > basically anything… That was my initial reaction, too, but it's actually pretty trivial to do static initialisation already, thanks to the way autoloading works. For instance if you put the below in "Foo.php", then it will be run once the first time class "Foo" is loaded: class Foo {    public static $bar; } Foo::$bar = new Whatever(); This has essentially the same effect as writing this: class Foo {    public static $bar = new Whatever(); } Which is absolutely horrible if Whatever's constructor has side effects, but then most things are going to be horrible if your constructors have side effects... Regards, -- Rowan Tommins [IMSoP]