Re: [RFC] Lazy Objects
| From: | Larry Garfield | Date: | Wed, 24 Jul 2024 14:02:31 +0000 |
| Subject: | Re: [RFC] Lazy Objects | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-124572@lists.php.net to get a copy of this message | ||
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 that is lazy by
default? Just make everything lazy with a fairly standard initializer or factory, unless a specific
case says you shouldn't. That way you can use optional dependencies in a constructor pretty
much at will with no overhead of needing to create a chain of dependencies as a result.
Would that be a bad idea for some reason, or would it actually work?
(This doesn't really affect my vote, more just a thought that came up.)
--Larry Garfield