Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124575 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 8F94A1A00B7 for ; Wed, 24 Jul 2024 14:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721831393; bh=2GMxflTXLSEcp4G/gnN+EmVUU9tm1AvnKSq7DstqKH0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OXe7ahsRlmywDDwKF6uRjOLdia7a+iMfdGLRFwDlZyRw/MCJtrx7TGfXz5F/suWL9 AKtzR+bYwj8oZnyLAcgj4r3ssTKy2BfRHnBhkUo4jyH38A+qwp4w6fVBcBustfegI/ U5H1RigHRtl8qRqpaRbkF9Zj3VHCFejAxvM2AHx1A11eoAOtuQhsAu3IFIVjw6JVw6 4O+bh6qJphgMy3YyVqvYIPusMoRjl7pgjF5h7Vf/UADttIDoBhN639jYMW1NSggUxJ Fk/YXpgX+6YSIfGoov6o9+c1DYi4yjqNiWW53e4zOaPns59enIgZEwhceKkATrgPZ1 vBmGawwzZD2CA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0C34318002E for ; Wed, 24 Jul 2024 14:29:53 +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 autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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, 24 Jul 2024 14:29:51 +0000 (UTC) Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-52f04c1e58eso4693219e87.3 for ; Wed, 24 Jul 2024 07:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721831296; x=1722436096; 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=lLPYMgAwwPjLpxCVWmKoQyivBTHBuWgnsQjGFwb3EdY=; b=nOG7ecDKsOu4zwzA4Ur/aoOKSj/Q3D6HnxVu8JzNksWWmpJp47fKtUUKGM6NWd3MIE yxqBIy4CLWpzCtLEdJ1OwvzSBNCZBaqocrzd1q6RjLnAnQqA6A7bPWTmeCjTELkIL8Sc +4lz/8PFN9mL8DEqLyE6D+ab+NBISZpsuNNWdBtu4bX/atpTLWIRy/ZoRyZ05FSQbyXk QJ7uOUoMxk1xglNXUsQwQILJR7yWMtm89VrXHbYh6YOLpAE4xmrdc73qUla6J4tU9MXh PM3d3Qfqm3QdOEZ2fYSpZRIzknVZY4/f/XqwvfRvTbzeHW4GuZsUnqVFd0PRE/0nehvn o1qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721831296; x=1722436096; 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=lLPYMgAwwPjLpxCVWmKoQyivBTHBuWgnsQjGFwb3EdY=; b=EmTo1o6l8aXwbGe3f6q10vFufiwtQGdrmzVe6/jHWQAtFqe9QPR+hcDbxA3sbTMuiZ ylXvPAiguOIJJEUaYcYm2HPxE6a8fIJgtylZNck5zslmQZjn0sAcQOD1ncQ8wCX2xCWF punviY1K60ufPtldtdb80dwO/9JpvVv7Simg01tdfGhBBRBm5t50GUNahbH0MQE/GE/J sfHUspGO6xeUQLi9YzGh+rXqvWsIhs1qSm9XRhLpsE9jRQQ5th49YtHDLsthnId/pRGO SDlOt+rc4PiBnAbq9VmWRj509APdq/awdo7QYTg1Bct+ao5JyC4J+BUwsrCUzKPqXCjK XhJg== X-Gm-Message-State: AOJu0Yyl3LwruvqPWW0Wjtl7gJoJNg7NMqcgJRiko2kIuUGBYPQYKVVm Ik08KWWf7KMmRw/ON1mDwflhhiCrQq6KFQcijrTcYM4k/u9GW3H7MR6DebU81UsrsLG6/jcnqLb NgyM43ag/ycB5WBRvR1af4jKwtZOVofy4 X-Google-Smtp-Source: AGHT+IEKf2CZnA8QpbbfWO6drBAU9I0aPf/vscwdLbcHhzSTMhJNnVFD6dLILHZqTj2p4DDUFl6ZBhpOd72VDr0qjXM= X-Received: by 2002:a05:6512:4011:b0:52c:9877:71b7 with SMTP id 2adb3069b0e04-52fcdaa8ea8mr3007973e87.59.1721831295485; Wed, 24 Jul 2024 07:28:15 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <1118bbcd-a7b4-47bf-bf35-1a36ab4628e1@bastelstu.be> <45847b93-02bf-459f-bcd2-81ba35a12c24@bastelstu.be> <46bd4098-2936-4e46-98e9-fe55118325c2@bastelstu.be> <61ab36bc-b045-452a-84e0-87367d4c680e@bastelstu.be> <07e065f2-8f64-4bad-9a98-51f4eaf63ddb@app.fastmail.com> <2a0a4650-c2c5-4c6d-ad3a-25365b3391b2@bastelstu.be> <2fd6d80d-a55c-4aad-aeee-6d07d4b930a1@app.fastmail.com> In-Reply-To: <2fd6d80d-a55c-4aad-aeee-6d07d4b930a1@app.fastmail.com> Date: Wed, 24 Jul 2024 16:28:01 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Lazy Objects To: Larry Garfield , Rob Landers Cc: php internals Content-Type: multipart/alternative; boundary="000000000000bb13b9061dff1617" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000bb13b9061dff1617 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le mer. 24 juil. 2024 =C3=A0 16:05, Larry Garfield = a =C3=A9crit : > On Thu, Jul 18, 2024, at 7:12 AM, Nicolas Grekas wrote: > > >> Otherwise, I'm quite looking forward to this. > > > > =F0=9F=A4=9E > > 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.) I see no blockers. I don't have numbers nor plan to play with this idea in the short term but that could be fun to try :) Eg the Symfony DI could be updated to leverage the new mechanism (I did it already with a previous version of the RFC) and we'd try running an app with all services defined as lazy by default. 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. Nicolas --000000000000bb13b9061dff1617 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
Le=C2=A0mer. 24 juil. 2024 =C3=A0=C2= =A016:05, Larry Garfield <larr= y@garfieldtech.com> a =C3=A9crit=C2=A0:
On Thu, Jul 18, 2024, at 7:12 AM, Nicolas = Grekas wrote:

>> Otherwise, I'm quite looking forward to this.
>
> =F0=9F=A4=9E

Another thought that occurred to me.=C2=A0 Given how lightweight it *looks*= to be (may not actually be, but looks it), how much overhead would there b= e to having a compiled DI container that is lazy by default?=C2=A0 Just mak= e everything lazy with a fairly standard initializer or factory, unless a s= pecific case says you shouldn't.=C2=A0 That way you can use optional de= pendencies 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.)=

I see no blockers.

I don't have numbers nor plan to play with this idea in the short ter= m but that could be fun to try :)
Eg the Symfony DI could be upda= ted to leverage the new mechanism (I did it already with a previous version= of the RFC) and we'd try running an app with all services defined as l= azy by default.

To Rob: proxying by interface can = be implemented using regular code generation so it's not a blocker. Sym= fony does it already, and will continue to do it to cover the use case.

Nicolas
--000000000000bb13b9061dff1617--