Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123940 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 B6B721AD8EA for ; Thu, 27 Jun 2024 14:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719499171; bh=0IzwFzOozJahb2ZO0A1kAJObjCCHmpWDfz2s0l6Ysyo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HAuims6eHrAelyJbmlj8xyzNwmYOC83HYdO98R++Ztra7vnDDKqleBzrhm9amYLR4 blJA7xqAv7Fy72TlH6SZ7mfJeNi/mnemLjqbZKZzJmVHx73A5FVYPrNLkVYpI7PZEq iJj0GPzrn6f0ks7PkkKOuhjpB5iTDYQG/WLFvbFDRbiUh3rzyG19F7jHOdVtWLtd1h x6+zgqb8MxgnuspCx+Re1VYTLdPxdza1VuUqe47uR9Cra1b1OfrDSpn15RPjvt4RUT LvqoRX+uHqDcoZGY4MTHp9K+VtuBjaDqYdEFxir1QZ69NUf3xKkLTPfy/f/9dK1ccn E2o4AcNsAiU8Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0D0621806CC for ; Thu, 27 Jun 2024 14:39:30 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, 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=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-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 ; Thu, 27 Jun 2024 14:39:26 +0000 (UTC) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a724b3a32d2so634250566b.2 for ; Thu, 27 Jun 2024 07:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719499087; x=1720103887; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0IzwFzOozJahb2ZO0A1kAJObjCCHmpWDfz2s0l6Ysyo=; b=HlBI26O8BwQi06KCiETp92kOGoNdA3AEKnrg0vkqHF7EwbT14Z2R8LPcbvd90nmlHV GYkxXrHxqUvPxaKVq/oMoCSh523TegypKEcnkJuta5Z4AZEiBaLO49fvcJIG/t7IKlNc zs4Wv4baNI2IyOPM+m6TjyanVIVXXYedCU9LI+asEqF4OFLcB3j3XE374ncKP4qAhj2G NYuVDbkjqUcvI2HGPz9AkRGgeV3GB+hsEG+Tacr2LsYk3pKZvz3GxwAgREd/VHc+9sx0 QXLglu6bVOiMSaVRRP8IwiEaeWeFHq1yXsbQ/qBsQDCERxOTiSGGPY9rfvcM0VEOYfdo CgHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719499087; x=1720103887; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0IzwFzOozJahb2ZO0A1kAJObjCCHmpWDfz2s0l6Ysyo=; b=JI1dytvsEbWygyI+JvHg/Xd8UaoA6gjL1eFUV5qnl++10i8NW+6FUu5sl1XjXI/rRn xVfBazjGeclAhUN2JRNkp8VIeGPp/In0UonaPtR2wiLJO3wW9a5VAtRYSdAQivYyirPW AaJbMck/xCtTpc+Uj8/qxJWtrQtGlA69kjgzKxITYrqBYep/Sdh/F91Hwx6ykrLK/fbC rZA9d+qRvZjGiA0afmvfyIW1y69MuqZuQJaga0BlpDXqJfc7QcmaKSUwRh8pIZbNuGaM 8+vWsfAUtqiTmGLOgnHZmPgEUD20ogGCY9+Cu4rnRWLe9jNWFglHeKDJ+n/sk4Mk5Mjh pWMg== X-Forwarded-Encrypted: i=1; AJvYcCUxZxRhGgppU+YXColu08jBQCESLxqnIe0sJGa2YKkncyEGQNHpUItvCWLLR204hhdmXtt12M23Ls37w6D2U9ZPqLkLmInuaQ== X-Gm-Message-State: AOJu0YwHYhudCzHHyOLiVWSD25UkzhSZ9cpNzXvGX+eGppGZCbhB+b0U vodJ7EwGs0UODrIHcspYeJ1lilz98QbjWi8wz62oIGbgM80SKf/Bg9cQ3gRL/ffoKIhYBiv8cKj PYyy1jaXGhGrxQs/pMDLQTDtzvUs= X-Google-Smtp-Source: AGHT+IGWvsdHq42uIiRxYGgCoenY6nIayKwmZnpYjdvmgz0I9KiT/Ej18v4ckACHVTkgVqbR+K/5+3a2nrGuJXrgXOM= X-Received: by 2002:a17:907:1689:b0:a72:8d2f:859c with SMTP id a640c23a62f3a-a728d2f88cfmr369813466b.33.1719499087027; Thu, 27 Jun 2024 07:38:07 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 27 Jun 2024 16:37:55 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Lazy Objects To: Marco Pivetta Cc: Levi Morrison , Nicolas Grekas , PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: arnaud.lb@gmail.com (Arnaud Le Blanc) Hi Marco, On Thu, Jun 27, 2024 at 12:32=E2=80=AFPM Marco Pivetta = wrote: > > Hey Arnaud, > > On Wed, 26 Jun 2024 at 21:06, Arnaud Le Blanc wrote= : >> >> The proposed implementation is adding very little complexity as it's not= adding any special case outside of object handlers (except in json_encode(= ) and serialize() because these functions trade abstractions for speed). Fu= rthermore all operations that may trigger an object initialization are alre= ady effectful, due to magic methods or hooks (so we are not making pure ope= rations effectful). This means that we do not have to worry about lazy obje= cts or to be aware of them anywhere in the code base, outside of object han= dlers. >> >> To give you an idea, it's implemented by hooking into the code path that= handles accesses to undefined properties. This code path may call __get or= __set methods if any, or trigger errors, and with this proposal, may trigg= er the initialization. Userland implementations achieve this functionality = in a very similar way (with unset() and a generated sub-class with magic me= thods), but they have considerably more edge cases to handle due to being a= t a different abstraction level. > > > Assuming this won't pass a vote (I hope it does, but I want to be optimis= tic): is this something that could be implemented in an extension, or is it= only feasible in core? An extension could achieve similar behavior by decorating the default object handlers. However, it may have to re-implement a significant part of the object handlers logic, so that initialization is triggered at the right time. Best Regards, Arnaud