Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123880 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 40B621A009C for ; Wed, 26 Jun 2024 19:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719428791; bh=PhbkQBMSVKhdQvjmVDitJ1a2rSJSWvoRx1encx8U4K0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=M3VtXj+okpNEPi8rRvUj0xpaERlI8imCMwW3y+Y44NTHOQ9Y81gX3o/BUZCv0T/Fj sUpGpofjT0W5O+gQD5MQtGFn9M2QasuJ9z+bdqiyj7teXh851xuw0n76d31jWHcgJR O+jH0X7+ZZOjoBHjuHXjz3NUU5xnJ8ZsizuQfb8VAmuHEBkjyAhj/X8eovQDsNYx64 eCZdbUTz1b1BQvrhYuDZ4DbBlDrlc7RXzZwSE2w1ftJBtUs9dpkhQq442OTDm15Rqk 72SChFSUa24GdOBddt7NK/65mZrPb5cf2SUg5S2SP5zdzwwPSVPMbRUymUaOGcYAwz 8F+wE1DC7Cuuw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 59F321807E2 for ; Wed, 26 Jun 2024 19:06: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, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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, 26 Jun 2024 19:06:29 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-57d06101d76so794768a12.3 for ; Wed, 26 Jun 2024 12:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719428711; x=1720033511; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PhbkQBMSVKhdQvjmVDitJ1a2rSJSWvoRx1encx8U4K0=; b=U9G8teY6zgtVboNcZLWrktJa7psNmlyX7EUa9MsLAIbKRGTESCeblp2tFEWaX1qNtW FKZscPkNAl6w03q24DHWzqt7kKHoMgfhgIAGmoaSI+BVrAEL1NsxjmyEhwaEvqnAogDJ FTwGKURcHEBNzTu8KSdAUIrfS2/E/RZJtXgHGkDHAg5SRS0BmXKL8WVnsr9qqzZgT66M sGpVdR393iqyRyqFvXjr7MLBs7Tnb9boUZ1GxB2DBEnXnA+iqN4SYAsEeI8iC25+owgJ ulU28l7osGkX84bX1+9BA5rbOLKIwPw/j8dirg63Xk8QZz7Iyt/sIG1yRRQHR9obeO2r u0ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719428711; x=1720033511; h=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=PhbkQBMSVKhdQvjmVDitJ1a2rSJSWvoRx1encx8U4K0=; b=DwdhdhdQ8tt+4mol02DOCWsJRBdzIpWbW3Qis2A471diUcoWCy6c7DE7IxQwz4yIZT PiKuFRDFazGa3+xcqbA+0hTipF0Xe/QqZtt+yTkqWiSjGrQQL7H1plkWzx8EbP61/nq6 3/rqr38TlGEyMcnchA2UaEqImAtNJNCHLupcN7wzUCwnmxXTbnJZROcn/0n7WoaRgry+ V8xOxB4oCnCZXT+hTOYkgI8e08cE58o9PzORZiQ/cIFnuDkKNxm3UML0uuSdsUYAsGjO jtR/r5l/YCggO+3De7aYhaJ5+f9bO5UPA6d8kasRG4ZA5yMtoYs/+o24JoFulB2rAa/d zhJw== X-Forwarded-Encrypted: i=1; AJvYcCU3TutYqCrJF0m2VxgvNQ/Kd0PmAsXvQ00bx6TKSt0OK3uKk+ETbbv+xkRXYkWFULf3+enW3mXbU7Qgi5GOPGqZuT7i+7KNig== X-Gm-Message-State: AOJu0YzejW+xbQf2XY1D9vw1OTBnncUNAe00+uDNTob2X/IsYi4jIZ1y rVHzLlLwE8ULsST6YXfJs1uDSJWg2c4WXDG7G3LRazYGY8Kj5z1dOeZR3FsxCUjMsQwn1jwkbOA 2KMVpiS6mj5KFGJUlVv9XH8bzE5E= X-Google-Smtp-Source: AGHT+IHAsLPDF2rCooAMWtPz1hCJIfbTM1t/fCL+E6R7WWtpu6O1veQFFxMOHsx2VSCwpxG5JSYIE7fp1g1sXle7ePU= X-Received: by 2002:a50:a693:0:b0:57c:68fd:2bc9 with SMTP id 4fb4d7f45d1cf-57d49c976d1mr8802145a12.3.1719428710859; Wed, 26 Jun 2024 12:05:10 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 26 Jun 2024 21:04:58 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Lazy Objects To: Levi Morrison Cc: Nicolas Grekas , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000871070061bcfb1f9" From: arnaud.lb@gmail.com (Arnaud Le Blanc) --000000000000871070061bcfb1f9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Levi, On Wed, Jun 26, 2024 at 12:07=E2=80=AFAM Levi Morrison wrote: > I will vote no on this one. I do not believe the internal complexity > and maintenance is worth the feature. Additionally, I do not feel like > changing the language to support this feature is a good idea; if this > were a library only thing, I would not care. > Hi Levi, 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). Furthermore all operations that may trigger an object initialization are already effectful, due to magic methods or hooks (so we are not making pure operations effectful). This means that we do not have to worry about lazy objects or to be aware of them anywhere in the code base, outside of object handlers. 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 trigger the initialization. Userland implementations achieve this functionality in a very similar way (with unset() and a generated sub-class with magic methods), but they have considerably more edge cases to handle due to being at a different abstraction level. Best Regards, Arnaud --000000000000871070061bcfb1f9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Levi,

On Wed, Jun 26, 2024 at 12:07=E2=80=AFAM Levi Morrison <levi.morrison@dat= adoghq.com> wrote:
I will vote no on this one. I do not believe the internal complexity
and maintenance is worth the feature. Additionally, I do not feel like
changing the language to support this feature is a good idea; if this
were a library only thing, I would not care.

Hi Levi,

The proposed implementation is= =20 adding very little complexity as it's not adding any special case=20 outside of object handlers (except in json_encode() and serialize()=20 because these functions trade abstractions for speed). Furthermore all=20 operations that may trigger an object initialization are already=20 effectful, due to magic methods or hooks (so we are not making pure=20 operations effectful). This means that we do not have to worry about=20 lazy objects or to be aware of them anywhere in the code base, outside=20 of object handlers.

To give you an idea,=20 it's implemented by hooking into the code path that handles accesses to= =20 undefined properties. This code path may call __get or __set methods if=20 any, or trigger errors, and with this proposal, may trigger the=20 initialization. Userland implementations achieve this functionality in a very similar way (with unset() and a generated sub-class with magic=20 methods), but they have considerably more edge cases to handle due to=20 being at a different abstraction level.

Best Regar= ds,
Arnaud
=C2=A0
--000000000000871070061bcfb1f9--