Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-25 Thread Tim Düsterhus
Hi On 7/25/24 17:40, Arnaud Le Blanc wrote: Thank you! We have updated the RFC accordingly. LGTM :-) 5. In the explanation of "ReflectionClass::markLazyObjectAsInitialized()", it says: Its behavior is the same as described for Ghost Objects in the Initialization Sequence section, except

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-25 Thread Arnaud Le Blanc
Hi Tim, On Thu, Jul 25, 2024 at 4:47 PM Tim Düsterhus wrote: > I'm seeing there are some more changes and not just to the cloning > section. I've went through the entire RFC once again and here are my > (hopefully final) five remarks. They are only about textual > clarification of some

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-25 Thread Tim Düsterhus
Hi On 7/24/24 17:23, Nicolas Grekas wrote: Cloning has kept us busy in the last days and after many brainstorming sessions, we've decided to follow your initial proposal : make the clone operator trigger the initialization of the original object before cloning it. Thank you. That cloning

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-24 Thread Rob Landers
On Wed, Jul 24, 2024, at 22:45, Nicolas Grekas wrote: > > > Le mer. 24 juil. 2024 à 21:44, Rob Landers a écrit : >> __ >> >> >> On Wed, Jul 24, 2024, at 16:28, Nicolas Grekas wrote: >>> >>> To Rob: proxying by interface can be implemented using regular code >>> generation so it's not a

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-24 Thread Nicolas Grekas
Le mer. 24 juil. 2024 à 21:44, Rob Landers a écrit : > > > On Wed, Jul 24, 2024, at 16:28, Nicolas Grekas wrote: > > > To Rob: proxying by interface can be implemented using regular code > generation so it's not a blocker. Symfony does it already, and will > continue to do it to cover the use

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-24 Thread Rob Landers
On Wed, Jul 24, 2024, at 16:28, Nicolas Grekas wrote: > > To Rob: proxying by interface can be implemented using regular code > generation so it's not a blocker. Symfony does it already, and will continue > to do it to cover the use case. I'm not sure what you mean, as the RFC makes it look

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-24 Thread Nicolas Grekas
Hi, Le jeu. 18 juil. 2024 à 21:58, Tim Düsterhus a écrit : > Hi > > On 7/17/24 20:31, Nicolas Grekas wrote: > > A bit unrelated to the above topic: we've further clarified the RFC by > > addition restrictions to what can be done with lazy proxies. Namely, when > > the factory returns an object

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-24 Thread Nicolas Grekas
Le mer. 24 juil. 2024 à 16:05, Larry Garfield a écrit : > On Thu, Jul 18, 2024, at 7:12 AM, Nicolas Grekas wrote: > > >> Otherwise, I'm quite looking forward to this. > > > > 爛 > > Another thought that occurred to me. Given how lightweight it *looks* to > be (may not actually be, but looks it),

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-24 Thread Rob Landers
On Wed, Jul 24, 2024, at 16:13, Rob Landers wrote: > On Wed, Jul 24, 2024, at 16:02, Larry Garfield wrote: >> On Thu, Jul 18, 2024, at 7:12 AM, Nicolas Grekas wrote: >> >> >> Otherwise, I'm quite looking forward to this. >> > >> > 爛 >> >> Another thought that occurred to me. Given how

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-24 Thread Rob Landers
On Wed, Jul 24, 2024, at 16:02, Larry Garfield wrote: > On Thu, Jul 18, 2024, at 7:12 AM, Nicolas Grekas wrote: > > >> Otherwise, I'm quite looking forward to this. > > > > 爛 > > Another thought that occurred to me. Given how lightweight it *looks* to be > (may not actually be, but looks it),

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-24 Thread Larry Garfield
On Thu, Jul 18, 2024, at 7:12 AM, Nicolas Grekas wrote: >> Otherwise, I'm quite looking forward to this. > > 爛 Another thought that occurred to me. Given how lightweight it *looks* to be (may not actually be, but looks it), how much overhead would there be to having a compiled DI container

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-22 Thread Benjamin Außenhofer
Am 17.07.2024, 20:31:02 schrieb Nicolas Grekas : > Dear all, > > Le mar. 16 juil. 2024 à 17:51, Nicolas Grekas < > nicolas.grekas+...@gmail.com> a écrit : > >> Hi there, >> >> Le mar. 16 juil. 2024 à 10:13, Nicolas Grekas < >> nicolas.grekas+...@gmail.com> a écrit : >> >>> >>> >>> Le lun. 15

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-18 Thread Tim Düsterhus
Hi On 7/17/24 20:31, Nicolas Grekas wrote: A bit unrelated to the above topic: we've further clarified the RFC by addition restrictions to what can be done with lazy proxies. Namely, when the factory returns an object from a parent class, we describe that adding more on the proxy class would

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-18 Thread Tim Düsterhus
Hi On 7/12/24 08:47, Rob Landers wrote: I think it would be up to the developer writing the proxy framework to use or abuse this As I've just explained in my reply to Nicolas this is observable to the user and thus leaks implementation details of the proxy framework. Currently, clone's

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-18 Thread Tim Düsterhus
Hi On 7/15/24 10:23, Nicolas Grekas wrote: To me this is what the language evolution should do: Enable users to do things that previously needed to be provided by userland libraries, because they were complicated and fragile, not enabling userland libraries to simplify things that they should

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-18 Thread Arnaud Le Blanc
Hi Philip, On Thu, Jul 18, 2024 at 12:19 PM Philip Hofstetter wrote: > Super minor nitpick: You have updated the prototype, but not the explanation > text which still says: > >> When initialization is required, the $initializer is called with the object >> as first parameter. The initializer

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-18 Thread Philip Hofstetter
Hi, Minor point: Why is the $initializer return type null, instead of void? I >> don't see a purpose to allowing an explicit null return and nothing else. >> > > Updated to use "void". Both would work :) > > Super minor nitpick: You have updated the prototype, but not the explanation text which

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-18 Thread Nicolas Grekas
Le jeu. 18 juil. 2024 à 00:13, Larry Garfield a écrit : > On Wed, Jul 17, 2024, at 6:31 PM, Nicolas Grekas wrote: > > > A bit unrelated to the above topic: we've further clarified the RFC by > > addition restrictions to what can be done with lazy proxies. Namely, > > when the factory returns an

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-18 Thread Nicolas Grekas
Le jeu. 18 juil. 2024 à 09:08, Rob Landers a écrit : > On Wed, Jul 17, 2024, at 20:31, Nicolas Grekas wrote: > > Dear all, > > Le mar. 16 juil. 2024 à 17:51, Nicolas Grekas < > nicolas.grekas+...@gmail.com> a écrit : > > Hi there, > > Le mar. 16 juil. 2024 à 10:13, Nicolas Grekas < >

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-18 Thread Rob Landers
On Wed, Jul 17, 2024, at 20:31, Nicolas Grekas wrote: > Dear all, > > Le mar. 16 juil. 2024 à 17:51, Nicolas Grekas > a écrit : >> Hi there, >> >> Le mar. 16 juil. 2024 à 10:13, Nicolas Grekas > > a écrit : >>> >>>

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-17 Thread Larry Garfield
On Wed, Jul 17, 2024, at 6:31 PM, Nicolas Grekas wrote: > A bit unrelated to the above topic: we've further clarified the RFC by > addition restrictions to what can be done with lazy proxies. Namely, > when the factory returns an object from a parent class, we describe > that adding more on

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-17 Thread Nicolas Grekas
Dear all, Le mar. 16 juil. 2024 à 17:51, Nicolas Grekas a écrit : > Hi there, > > Le mar. 16 juil. 2024 à 10:13, Nicolas Grekas < > nicolas.grekas+...@gmail.com> a écrit : > >> >> >> Le lun. 15 juil. 2024 à 21:42, Tim Düsterhus a écrit : >> >>> Hi >>> >>> On 7/15/24 09:25, Nicolas Grekas

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-16 Thread Nicolas Grekas
Hi there, Le mar. 16 juil. 2024 à 10:13, Nicolas Grekas a écrit : > > > Le lun. 15 juil. 2024 à 21:42, Tim Düsterhus a écrit : > >> Hi >> >> On 7/15/24 09:25, Nicolas Grekas wrote: >> > Testing is actually a good domain where resetting lazy objects might >> open >> > interesting use cases. >>

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-16 Thread Nicolas Grekas
Le lun. 15 juil. 2024 à 21:42, Tim Düsterhus a écrit : > Hi > > On 7/15/24 09:25, Nicolas Grekas wrote: > > Testing is actually a good domain where resetting lazy objects might open > > interesting use cases. > > This reminded me about zenstruck/foundry, which leverages the > > LazyProxyTrait to

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-16 Thread Rob Landers
On Mon, Jul 15, 2024, at 21:23, Tim Düsterhus wrote: > Hi > > On 7/12/24 08:00, Rob Landers wrote: > > For what it’s worth, I see “resetAsLazy()” being most useful for unit > > testing libraries that build proxies. While this feature will remove most > > of the tricky nuances around proxies, it

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-15 Thread Tim Düsterhus
Hi On 7/15/24 11:59, Nicolas Grekas wrote: With refactoring, we can fix all design issues in all softwares. Yet that's too theoretical and this is missing the point IMHO. What we want to provide is a complete coverage of the lazy object domain. Simplifying too much can lead to an incomplete

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-15 Thread Tim Düsterhus
Hi On 7/15/24 09:25, Nicolas Grekas wrote: Testing is actually a good domain where resetting lazy objects might open interesting use cases. This reminded me about zenstruck/foundry, which leverages the LazyProxyTrait to provide refreshable fixture objects

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-15 Thread Tim Düsterhus
Hi On 7/12/24 08:00, Rob Landers wrote: For what it’s worth, I see “resetAsLazy()” being most useful for unit testing libraries that build proxies. While this feature will remove most of the tricky nuances around proxies, it doesn’t make it any easier in generating the code for them, so that

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-15 Thread Nicolas Grekas
Le ven. 12 juil. 2024 à 01:40, Benjamin Außenhofer a écrit : > > > Am 11.07.2024, 20:31:44 schrieb Tim Düsterhus : > >> Hi >> >> On 7/11/24 10:32, Nicolas Grekas wrote: >> >> > Many things are already possible in userland. That does not always mean >> >> > that the cost-benefit ratio is

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-15 Thread Nicolas Grekas
Le jeu. 11 juil. 2024 à 20:31, Tim Düsterhus a écrit : > Hi > > On 7/11/24 10:32, Nicolas Grekas wrote: > >> Many things are already possible in userland. That does not always mean > >> that the cost-benefit ratio is appropriate for inclusion in core. I get > >> behind the two examples in the

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-15 Thread Nicolas Grekas
Le ven. 12 juil. 2024 à 08:00, Rob Landers a écrit : > > > On Fri, Jul 12, 2024, at 01:40, Benjamin Außenhofer wrote: > > > > Am 11.07.2024, 20:31:44 schrieb Tim Düsterhus : > > Hi > > On 7/11/24 10:32, Nicolas Grekas wrote: > > > Many things are already possible in userland. That does not

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-15 Thread Nicolas Grekas
Le ven. 12 juil. 2024 à 12:55, Benjamin Außenhofer a écrit : > > > Am 21.06.2024, 12:24:20 schrieb Nicolas Grekas < > nicolas.grekas+...@gmail.com>: > >> Hi Ben, >> >> On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wrote: > > Hi Larry, > > > > Following your feedback we propose to

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-12 Thread Rob Landers
On Fri, Jul 12, 2024, at 09:52, Benjamin Außenhofer wrote: > > > Am 12.07.2024, 08:00:18 schrieb Rob Landers : >> >> >> >> On Fri, Jul 12, 2024, at 01:40, Benjamin Außenhofer wrote: >>> >>> >>> Am 11.07.2024, 20:31:44 schrieb Tim Düsterhus : Hi On 7/11/24 10:32, Nicolas

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-12 Thread Benjamin Außenhofer
Am 21.06.2024, 12:24:20 schrieb Nicolas Grekas : > Hi Ben, > > On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wrote: > Hi Larry, > > Following your feedback we propose to amend the API as follows: > > ``` > class ReflectionClass > { > public function

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-12 Thread Benjamin Außenhofer
Am 12.07.2024, 08:00:18 schrieb Rob Landers : > > > On Fri, Jul 12, 2024, at 01:40, Benjamin Außenhofer wrote: > > > > Am 11.07.2024, 20:31:44 schrieb Tim Düsterhus : > > Hi > > On 7/11/24 10:32, Nicolas Grekas wrote: > > > Many things are already possible in userland. That does not always mean >

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-12 Thread Rob Landers
On Thu, Jul 11, 2024, at 20:31, Tim Düsterhus wrote: > Hi > > On 7/11/24 10:32, Nicolas Grekas wrote: ... snip > > The $originalProxy is *not* shared with $clonedProxy. Instead, it's > > *initializers* that are shared between clones. > > And then, when we call that shared initializer in the

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-12 Thread Rob Landers
On Fri, Jul 12, 2024, at 01:40, Benjamin Außenhofer wrote: > > > Am 11.07.2024, 20:31:44 schrieb Tim Düsterhus : >> Hi >> >> On 7/11/24 10:32, Nicolas Grekas wrote: >>> > Many things are already possible in userland. That does not always mean >>> > that the cost-benefit ratio is appropriate

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-11 Thread Benjamin Außenhofer
Am 11.07.2024, 20:31:44 schrieb Tim Düsterhus : > Hi > > On 7/11/24 10:32, Nicolas Grekas wrote: > > > Many things are already possible in userland. That does not always mean > > > that the cost-benefit ratio is appropriate for inclusion in core. I get > > > behind the two examples in the “About

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-11 Thread Tim Düsterhus
Hi On 7/11/24 10:32, Nicolas Grekas wrote: Many things are already possible in userland. That does not always mean that the cost-benefit ratio is appropriate for inclusion in core. I get behind the two examples in the “About Lazy-Loading Strategies” section, but I'm afraid I still can't wrap my

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-11 Thread Nicolas Grekas
Le ven. 5 juil. 2024 à 21:49, Tim Düsterhus a écrit : > Hi > > On 7/2/24 16:48, Nicolas Grekas wrote: > > Thanks for the detailed feedback again, it's very helpful! > > Let me try to answer many emails at once, in chronological order: > > Note that this kind of bulk reply make it very hard for

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-05 Thread Tim Düsterhus
Hi On 7/2/24 17:49, Arnaud Le Blanc wrote: I'm curious, how did the implementation look like? Is there a proof of concept commit or patch available somewhere? As the author of the first internal enum (Random\IntervalBoundary) I had the pleasure of finding out that there was no trivial way to

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-05 Thread Tim Düsterhus
Hi On 7/2/24 16:48, Nicolas Grekas wrote: Thanks for the detailed feedback again, it's very helpful! Let me try to answer many emails at once, in chronological order: Note that this kind of bulk reply make it very hard for me to keep track of mailing list threads. It breaks threading, which

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-02 Thread Arnaud Le Blanc
Hi Tim, On Sun, Jun 30, 2024 at 3:54 PM Tim Düsterhus wrote: > On 6/27/24 16:27, Arnaud Le Blanc wrote: > >> * flags should be a `list` instead. A bitmask for > >> a new API feels unsafe and anachronistic, given the tiny performance hit. > >> > > > > Unfortunately this leads to a 30% slowdown

Re: [PHP-DEV] [RFC] Lazy Objects

2024-07-02 Thread Nicolas Grekas
Hi Valentin, Marco, Benjamin, Tim, Rob, Thanks for the detailed feedback again, it's very helpful! Let me try to answer many emails at once, in chronological order: The RFC says that Virtual state-proxies are necessary because of circular > references. It's difficult to accept this reasoning,

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-30 Thread Rob Landers
I just noticed in the RFC that I don't see any mention of what happens when running `get_class`, `get_debug_type`, etc., on the proxies, but it does mention var_dump.

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-30 Thread Tim Düsterhus
Hi On 6/27/24 16:27, Arnaud Le Blanc wrote: * flags should be a `list` instead. A bitmask for a new API feels unsafe and anachronistic, given the tiny performance hit. Unfortunately this leads to a 30% slowdown in newLazyGhost() when switching to an array of enums, in a micro benchmark.

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-30 Thread Tim Düsterhus
Hi On 6/30/24 15:08, Tim Düsterhus wrote: I've read the updated RFC and it's still not clear to me that returning an arbitrary “actual instance” object is sound. Especially when private properties - which for all intents and purposes are not visible outside of the class - are involved. Consider

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-30 Thread Tim Düsterhus
Hi On 6/22/24 00:22, Benjamin Außenhofer wrote: Given the complexities of newLazy* already, i am just trying to find arguments to keep the public surface of this API as small as posisble, as its intricacies are hard to grasp and simplicity / less ways to use it will be a benefit. So far i

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-30 Thread Tim Düsterhus
Hi I finally got around to giving the RFC another read. Please apologize if this email asks questions that have already been answered elsewhere, as the current mailing list volume makes it hard for me to keep up. On 6/14/24 14:13, Arnaud Le Blanc wrote: Is there any reason to call the

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-27 Thread Arnaud Le Blanc
Hi Marco, On Thu, Jun 27, 2024 at 12:32 PM 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()

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-27 Thread Arnaud Le Blanc
Hi Rob, On Wed, Jun 26, 2024 at 11:09 PM Rob Landers wrote: > Can you add to the RFC how to proxy final classes as well? This is mentioned > (unless I misunderstood) but in the proxy example it shows the proxy class > extending the proxied class (which I think is an error if the base class is

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-27 Thread Arnaud Le Blanc
Hi Marco, Thank you for the very detailed feedback. Please find my answers below. Nicolas will follow-up on some points. On Mon, Jun 24, 2024 at 1:03 AM Marco Pivetta wrote: > * lazy proxies should probably explore replacing object identity further > We have thought about a few approaches

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-27 Thread Rob Landers
On Thu, Jun 27, 2024, at 12:32, 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

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-27 Thread Marco Pivetta
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). >

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-26 Thread Rob Landers
On Tue, Jun 4, 2024, at 14:28, Nicolas Grekas wrote: > Dear all, > > Arnaud and I are pleased to share with you the RFC we've been shaping for > over a year to add native support for lazy objects to PHP. > > > Please find all the details here: > https://wiki.php.net/rfc/lazy-objects > > We

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-26 Thread Arnaud Le Blanc
Hi Gina, On Tue, Jun 25, 2024 at 5:59 PM Gina P. Banyard wrote: > The fact that an initialize() method has a $skipInitializer parameter > doesn't make a lot of sense to me. > Because at a glance, I don't see how passing true to it, and not calling > the method is different? > Calling

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-26 Thread Arnaud Le Blanc
Hi Levi, On Wed, Jun 26, 2024 at 12:07 AM 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

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-25 Thread Levi Morrison
On Tue, Jun 4, 2024 at 6:31 AM Nicolas Grekas wrote: > > Dear all, > > Arnaud and I are pleased to share with you the RFC we've been shaping for > over a year to add native support for lazy objects to PHP. > > Please find all the details here: > https://wiki.php.net/rfc/lazy-objects > > We look

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-25 Thread Gina P. Banyard
On Tuesday, 4 June 2024 at 13:28, Nicolas Grekas wrote: > Dear all, > > Arnaud and I are pleased to share with you the RFC we've been shaping for > over a year to add native support for lazy objects to PHP. > > Please find all the details here: > https://wiki.php.net/rfc/lazy-objects > > We

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-23 Thread Marco Pivetta
Hey Nicolas, Arnaud, On Tue, 4 Jun 2024 at 14:29, Nicolas Grekas wrote: > Please find all the details here: > https://wiki.php.net/rfc/lazy-objects > First of all, let me say that this is a fantastic RFC: having maintained both mine and Doctrine's version of lazy proxies for many years, this

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-21 Thread Benjamin Außenhofer
On Fri, Jun 21, 2024 at 12:24 PM Nicolas Grekas < nicolas.grekas+...@gmail.com> wrote: > Hi Ben, > > On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wrote: > Hi Larry, > > Following your feedback we propose to amend the API as follows: > > ``` > class

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-21 Thread Tim Düsterhus
Hi On 6/20/24 10:49, Nicolas Grekas wrote: While Arnaud works on moving the code to the updated API, are there more comments on this RFC before we consider opening the vote? I plan to give the RFC another read-through, but will likely not get around to it before the next week. Best regards

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-21 Thread Nicolas Grekas
Hi Ben, On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wrote: >>> > Hi Larry, >>> > >>> > Following your feedback we propose to amend the API as follows: >>> > >>> > ``` >>> > class ReflectionClass >>> > { >>> > public function newLazyProxy(callable $factory, int $options): >>> object {}

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-20 Thread Benjamin Außenhofer
On Thu, Jun 20, 2024 at 10:52 AM Nicolas Grekas < nicolas.grekas+...@gmail.com> wrote: > > > Le mar. 18 juin 2024 à 22:59, Larry Garfield a > écrit : > >> On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wrote: >> > Hi Larry, >> > >> > Following your feedback we propose to amend the API as

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-20 Thread Marco Pivetta
Hey Nicolas, On Thu, 20 Jun 2024 at 10:50, Nicolas Grekas wrote: > While Arnaud works on moving the code to the updated API, are there more > comments on this RFC before we consider opening the vote? > Due to IRL events, I haven't checked the text thoroughly yet, but I think I should, given

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-20 Thread Nicolas Grekas
Le mar. 18 juin 2024 à 22:59, Larry Garfield a écrit : > On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wrote: > > Hi Larry, > > > > Following your feedback we propose to amend the API as follows: > > > > ``` > > class ReflectionClass > > { > > public function newLazyProxy(callable

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-18 Thread Larry Garfield
On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wrote: > Hi Larry, > > Following your feedback we propose to amend the API as follows: > > ``` > class ReflectionClass > { > public function newLazyProxy(callable $factory, int $options): object {} > > public function newLazyGhost(callable

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-18 Thread Arnaud Le Blanc
Hi Larry, Following your feedback we propose to amend the API as follows: ``` class ReflectionClass { public function newLazyProxy(callable $factory, int $options): object {} public function newLazyGhost(callable $initializer, int $options): object {} public function

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-16 Thread Larry Garfield
On Sun, Jun 16, 2024, at 8:46 AM, Arnaud Le Blanc wrote: > On Sat, Jun 15, 2024 at 7:13 PM Larry Garfield wrote: >> > In practice I expect there will be two kinds of ghost initializers: >> > - Those that just call one public method of the object, such as the >> > constructor >> > - Those that

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-16 Thread Arnaud Le Blanc
On Sat, Jun 15, 2024 at 7:13 PM Larry Garfield wrote: > > In practice I expect there will be two kinds of ghost initializers: > > - Those that just call one public method of the object, such as the > > constructor > > - Those that initialize everything with ReflectionProperty::setValue() > > as

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-15 Thread Larry Garfield
On Sat, Jun 15, 2024, at 8:28 AM, Arnaud Le Blanc wrote: > Hi Larry, > >> Under Common Behavior, you have an example of calling the constructor >> directly, using the reflection API, but not of binding the callable, which >> the text says is also available. Please include an example of that so

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-15 Thread Arnaud Le Blanc
Hi Larry, On Fri, Jun 14, 2024 at 10:18 PM Larry Garfield wrote: > > The actual instance is allowed to escape the proxy and to create direct > > references to itself. > > How? Is this a "return $this" type of situation? This could use more > fleshing out and examples. "return $this" will

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-14 Thread Larry Garfield
On Fri, Jun 14, 2024, at 8:15 PM, Larry Garfield wrote: And of course I got the code sample wrong. It should be: > class Service { > public function __construct(private ServiceA $a, private ServiceB $b) {} > } > > $c = some_container(); > > $init = fn() =>

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-14 Thread Larry Garfield
On Fri, Jun 14, 2024, at 12:13 PM, Arnaud Le Blanc wrote: > Hi Tim, > > We have updated the RFC to address your feedback. Please find > additional answers below. The updated RFC looks much better, thank you. Though I still have some thoughts, in no particular order. > The actual instance is

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-14 Thread Tim Düsterhus
Hi On 6/14/24 14:13, Arnaud Le Blanc wrote: We have updated the RFC to address your feedback. Please find additional answers below. for some preliminary feedback: I've given the RFC another quick read and it already reads *much* better, thank you. The two examples for the two strategies

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-14 Thread Arnaud Le Blanc
Hi Michał, Chris, On Thu, Jun 6, 2024 at 8:53 AM Michał Marcin Brzuchalski wrote: > Did you consider implementing it using some attribute? On Sun, Jun 9, 2024 at 1:24 AM Chris Riley wrote: > I'm wondering why this has been attached to the existing reflection API > instead of being a new thing

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-14 Thread Arnaud Le Blanc
Hi Tim, We have updated the RFC to address your feedback. Please find additional answers below. On Wed, Jun 5, 2024 at 8:25 PM Tim Düsterhus wrote: > Is there any reason to call the makeLazyX() methods on an object that > was not just freshly created with ->newInstanceWithoutConstructor() >

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-08 Thread Chris Riley
On Tue, 4 Jun 2024 at 13:29, Nicolas Grekas wrote: > Dear all, > > Arnaud and I are pleased to share with you the RFC we've been shaping for > over a year to add native support for lazy objects to PHP. > > Please find all the details here: > https://wiki.php.net/rfc/lazy-objects > > We look

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-06 Thread Michał Marcin Brzuchalski
Hi Arnaud, śr., 5 cze 2024 o 20:08 Arnaud Le Blanc napisał(a): > Hi Larry, > > Thank you for the feedback. > > I think you got the two strategies right. However, there is a use-case > in which an object manages its own laziness by making itself lazy: > > ``` > class C { > public function

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Tim Düsterhus
Hi On 6/5/24 17:25, Nicolas Grekas wrote: Yes! See https://github.com/nicolas-grekas/symfony/pull/44 for Symfony. All the complex code is gone \o/ [...] For Doctrine, the URL is https://github.com/nicolas-grekas/doctrine-orm/pull/6 for now, with the most important line being the removal of the

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Tim Düsterhus
Hi Thank you Larry for your email. Your suggested API is basically what I also had in mind after Arnaud's clarification. On 6/5/24 20:06, Arnaud Le Blanc wrote: I think you got the two strategies right. However, there is a use-case in which an object manages its own laziness by making itself

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Tim Düsterhus
Hi Working through your reply in order of the email, without any backtracking, because the complexity of this topic makes it hard to keep the entire email in mind. This might mean that I am asking follow-up questions that you already answered further down. Please apologize if that is the

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Arnaud Le Blanc
Hi Larry, Thank you for the feedback. I think you got the two strategies right. However, there is a use-case in which an object manages its own laziness by making itself lazy: ``` class C { public function __construct() { ReflectionLazyObject::makeLazyGhost($this,

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Robert Landers
On Wed, Jun 5, 2024 at 6:58 PM Nicolas Grekas wrote: > > Hi Tim, > > Thanks for the detailed feedback. Arnaud already answered most of your > questions, here is the remaining one: > >> On 6/4/24 14:28, Nicolas Grekas wrote: >> > Please find all the details here: >> >

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Larry Garfield
On Wed, Jun 5, 2024, at 2:50 PM, Arnaud Le Blanc wrote: > Good point. The Mutex constructor is called during "new Mutex()", but > the object is made lazy after that, and the destructor is never > called. > > We have made the following changes to the RFC: > > - makeLazyGhost / makeLazyProxy will

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Nicolas Grekas
Hi Tim, Thanks for the detailed feedback. Arnaud already answered most of your questions, here is the remaining one: On 6/4/24 14:28, Nicolas Grekas wrote: > > Please find all the details here: > > https://wiki.php.net/rfc/lazy-objects > > > > We look forward to your thoughts and feedback. > >

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Arnaud Le Blanc
Hi Tim, That's a lot of interesting feedback. I will try to answer some of your points, and Nicolas will follow with other points. On Tue, Jun 4, 2024 at 9:16 PM Tim Düsterhus wrote: > - int $options = 0 > > Not a fan of flag parameters that take a bitset, those provide for a > terrible DX due

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-05 Thread Robert Landers
On Tue, Jun 4, 2024 at 10:23 PM Tim Düsterhus wrote: > > Hi > > On 6/4/24 14:28, Nicolas Grekas wrote: > > Please find all the details here: > > https://wiki.php.net/rfc/lazy-objects > > > > We look forward to your thoughts and feedback. > > I've gave the RFC three or four passes and I'm not

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-04 Thread Tim Düsterhus
Hi On 6/4/24 14:28, Nicolas Grekas wrote: Please find all the details here: https://wiki.php.net/rfc/lazy-objects We look forward to your thoughts and feedback. I've gave the RFC three or four passes and I'm not quite sure if I follow everything, here's a list of some questions / remarks

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-04 Thread Nicolas Grekas
Hello Valentin, Thanks for having a look. > Arnaud and I are pleased to share with you the RFC we've been shaping for >> over a year to add native support for lazy objects to PHP. >> >> Please find all the details here: >> https://wiki.php.net/rfc/lazy-objects >> >> We look forward to your

Re: [PHP-DEV] [RFC] Lazy Objects

2024-06-04 Thread Valentin Udaltsov
On June, 4 at 15:32, Nicolas Grekas wrote: > Dear all, > > Arnaud and I are pleased to share with you the RFC we've been shaping for > over a year to add native support for lazy objects to PHP. > > Please find all the details here: > https://wiki.php.net/rfc/lazy-objects > > We look forward to

[PHP-DEV] [RFC] Lazy Objects

2024-06-04 Thread Nicolas Grekas
Dear all, Arnaud and I are pleased to share with you the RFC we've been shaping for over a year to add native support for lazy objects to PHP. Please find all the details here: https://wiki.php.net/rfc/lazy-objects We look forward to your thoughts and feedback. Cheers, Nicolas and Arnaud