Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123688 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 97D9B1A009C for ; Wed, 19 Jun 2024 21:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718834196; bh=bcjOsxBM/4WC9cWHb1umKk/oJuJm725zwDcbdFcdtRE=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=g+bKxrcnivx9gJ6TMo9KrcGVVBX7hrnkd9W08Q1BEO//1CVFfdTY+3ueblRUi9M1D 27axTmMu0g0005Dj6P5GZZS9E7iWDAFY++DDCkzv50klbbbQTqInvfmVBDdG4RcYTU xZf4WmAiM2/fXtO/8lBMkA8BhtKepAkGQYShDYkd6ED9vQUM45SyahZdRVwlGloab7 6dxNjXix+JdiToiIMSqa95z9jLtVVeaWYFD3FA/09bQEp6DPlKWZ+1NNyDLHNeeo1X yMZlrbhd86UcY0Ejk3No2Ti64pdgwbPhu+UOf+jWwIZzVPWsIyct96+FwK4AWtJRNH rLxGuOWGDmCyg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BB50A180038 for ; Wed, 19 Jun 2024 21:56:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 19 Jun 2024 21:56:35 +0000 (UTC) Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e0272692096so232428276.1 for ; Wed, 19 Jun 2024 14:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1718834121; x=1719438921; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=wajGZ+AoOZtxMI3Yt41JjJkQN1eg8G1iFIUFxn4Fecw=; b=djyjYtJiN/1kNQJYC7O2xXq8k8niStlM0un6H2Hjvk8T4bPSVHAsuiIbtAiOniUTYo Sd/u6ee0qctHcyeeu17gjjrFUxVQrwL6/6Re/Tr5JgHPRgaC3U0fQkFYkU43VreU19IW QiSK4pqZ7dVm80LM4aJi2sOoXWpni0mMuK9en9MuWFePWwSz5e7mQMTMe19I/X8WR8JB xmvcgA6K151ir4vYETPFFt8SjuvufVuANh1yrHIST8yLxOhnndfoXZ9LVOMUxiRghxzl GM+gIzb8qiymQBywXLu3RF1Lr70P6sh5oZpaA6VS45+W3un7n3xmUk/HpxCc186F0NqQ GkfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718834121; x=1719438921; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wajGZ+AoOZtxMI3Yt41JjJkQN1eg8G1iFIUFxn4Fecw=; b=oO7qF7vTsZuSWl/Go9sBU9HIrkg7ucJ6VKrhe1AM9N6ktmHX15A2afjkHsjJq63Xx1 uEI6ELTq9d53W5C1SZSF9ly6yXsxeVypZUQBfY8o059k00vWv7sRq1sPMKjwPYtvKQWc YebvHZDJCuRjz2bZp/fGeWLyWt3rjqMtesTkmIvXO2u+dGLJdU+DheXBsoo5l31OWVTt Up+QT54wIG5MwOI4fpTUbLPKQGKG2VUNUOzymhu9kcWHRJTHaqeDZKticboqQsRq9SqS yLDEQCJGUYEIVeadXjQlahrpjh8iaCpE+j8DP7Ugvd8Bh5ljFIMUMe1ZLvxXu5up7tiC xxGA== X-Gm-Message-State: AOJu0Yw8ZonHOp8D8rlLgR4S7JWxmopM9bVo1OmI5J94WI+uXsLmejn0 HYZUR57WKyepEYOgJiNMQ3srzYTcmifnLY04VToU5tyhzJDuS3hu266hcW8kI9Hu+97cuY19rnL nOD8= X-Google-Smtp-Source: AGHT+IEzsEOYyeMOvxD4oHOT0PYxQ5OTJSRUsjkl0ECEk+b+yw/LaOaabgl65Rc/Vl7+3CMlzPm1Lg== X-Received: by 2002:a25:df0d:0:b0:dfe:35f6:2b4f with SMTP id 3f1490d57ef6-e02be167ab5mr3990972276.34.1718834120736; Wed, 19 Jun 2024 14:55:20 -0700 (PDT) Received: from smtpclient.apple (c-98-252-216-111.hsd1.ga.comcast.net. [98.252.216.111]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-dff04a924d2sm2871920276.60.2024.06.19.14.55.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2024 14:55:19 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_AE5FE2D3-94A4-41B7-A415-C1DD3C807C0E" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.8\)) Subject: Re: [PHP-DEV] [RFC] Static Constructor Date: Wed, 19 Jun 2024 17:55:18 -0400 In-Reply-To: Cc: php internals To: Ilija Tovilo References: X-Mailer: Apple Mail (2.3696.120.41.1.8) From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_AE5FE2D3-94A4-41B7-A415-C1DD3C807C0E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 19, 2024, at 2:36 PM, Ilija Tovilo = wrote: > On Wed, Jun 19, 2024 at 2:34=E2=80=AFPM Erick de Azevedo Lima > wrote: >> New expressions continue to not be supported in (static and = non-static) property initializers and class constant initializers. The = reasons for this are twofold: >> [snip] >> For static property initializers and class constant initializers a = different evaluation order issue arises. Currently, these initializers = are evaluated lazily the first time a class is used in a certain way = (e.g. instantiated). Once initializers can contain potentially = side-effecting expressions, it would be preferable to have a more = well-defined evaluation order. However, the straightforward approach of = evaluating initilizers when the class is declared would break certain = existing code patterns. In particular, referencing a class that is = declared later in the same file would no longer work. >=20 > Lazy evaluation might be ok if order is clearly defined. Consider that some uses for a static function need to always occur no = matter whether or not any other method of the class is called. My = previous email [1] covered several. Here [2] is a discussion on StackOverflow of "hooks" that should be = eagerly loaded. Thus I think it important that if lazy evaluation is used for static = initializers then it should be an option, and ideally one that is opt-in = vs. opt-out, e.g.: class Foo { private static lazy function __staticConstruct():void { // Do initialization stuff here } } -Mike [1] https://externals.io/message/123675#123684 = [2] https://stackoverflow.com/a/2400206/102699 = =20= --Apple-Mail=_AE5FE2D3-94A4-41B7-A415-C1DD3C807C0E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On = Jun 19, 2024, at 2:36 PM, Ilija Tovilo <tovilo.ilija@gmail.com> wrote:
On Wed, Jun 19, 2024 at 2:34=E2=80=AFPM Erick de Azevedo = Lima
<ericklima.comp@gmail.com> wrote:
New expressions continue = to not be supported in (static and non-static) property initializers and = class constant initializers. The reasons for this are twofold:
[snip]
For static property initializers and = class constant initializers a different evaluation order issue arises. = Currently, these initializers are evaluated lazily the first time a = class is used in a certain way (e.g. instantiated). Once initializers = can contain potentially side-effecting expressions, it would be = preferable to have a more well-defined evaluation order. However, the = straightforward approach of evaluating initilizers when the class is = declared would break certain existing code patterns. In particular, = referencing a class that is declared later in the same file would no = longer work.

Lazy evaluation = might be ok if order is clearly defined. =

Consider that = some uses for a static function need to always occur no matter whether = or not any other method of the class is called. My previous email [1] = covered several.

Here [2] is a = discussion on StackOverflow of "hooks" that should be eagerly = loaded.

Thus I think it important = that if lazy evaluation is used for static initializers then it = should be an option, and ideally one that is opt-in vs. opt-out, = e.g.:

class Foo {
  =   private static = lazy function __staticConstruct():void {
  =       // Do initialization stuff here
  =   }
}


-Mike
= --Apple-Mail=_AE5FE2D3-94A4-41B7-A415-C1DD3C807C0E--