Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124574 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 A4EED1A00CA for ; Wed, 24 Jul 2024 14:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721830604; bh=ma7bNazhqyAzBcs0RcGsGaofpGXHS+WHmVsoW7SjbRM=; h=In-Reply-To:References:Date:From:To:Subject:From; b=W+CYM+APE+yi0cyG4IUZz/7r22kuBEIIsGKdZQNVKcQm8j5VheYucsrlwDhxUHZyu sh/lh/fd8SWhSCWZk6GX8+vIKM71Rq8hTYygDM4Hl5IproqH8Fja6BmWz3M04Q62W4 NvCGjWsZp5QqiJqLX8x8qzNFGN4SpLJy/9DhX/7ylYun7bKMlzQa8sMdTkbbeJK0q+ hp25+frY3qwq7GKuzF2FvAbumjanTiSkX7SxfHdrggpVvpUcFRcIo9V5pTOeN9y4FW 2IwsK2bhFLtEkagc8IIIz5WWbRnj6xgW2yy9ZDQqA7depYtyxn31lO5ltY6jrtJWE3 EOY4JYwy1Ps7w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8A31F1801E0 for ; Wed, 24 Jul 2024 14:16:42 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout8-smtp.messagingengine.com (fout8-smtp.messagingengine.com [103.168.172.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 24 Jul 2024 14:16:40 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id E694C13801E3 for ; Wed, 24 Jul 2024 10:15:05 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute3.internal (MEProxy); Wed, 24 Jul 2024 10:15:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1721830505; x=1721916905; bh=fmgdQp1lIn CzNUKvtiaau6v71xx0Ahod6d9CRNaWLQg=; b=H16wv7wopVkbEr0BhxQKKop9yN IGg/4KvRrgcmAdkvW7vpr9aN/4uPQ6VN5UiNB1sCE9xSWH5w5W5lH1JH40ByyCgT edvO+HjCtG3h1jItrVkvdGHLGS3La0ILn2hMTC8YcveNrixYuka5Wa2mkEuRuCf8 7uObu36JAruBcDt4M6YI68ZgvC0YROMDBseqwnZHwFfj0CsHplRabPXNCA6iNuD0 BWfHDI2OLorsXmeIhPPa22mnhSXxcMvYRfT8YJF0HD5qoT4c5YTZJqk6LpjaK1dQ BY5Jl62MC3yMim4L3+GHGX1zi4TGvwi3sKFnC8GXTTndX9A0fQ3mi7W89Mnw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1721830505; x=1721916905; bh=fmgdQp1lInCzNUKvtiaau6v71xx0 Ahod6d9CRNaWLQg=; b=cJWo07w55zplQ0ubFS5eK3VtOnNAUkY6bQNrZCJv0vui BEu4YfeMWE6KLYxG+F2/dopxuvmUCRbZs+JHdh5JV4fXx6UlOMsZfGduAwULCMpV +cbiir3PV1mtLkNGq4ZLnN3I18X6mn2ySpY4gmg26mBxUztByVVwPXG1/t8ssjfd VckvNyWQnaPx4aG8b+OQChr6S8xKlYHiOVePZTOI7+XPOOII4K8yGuD8VxfmBL30 nYpoqZNvyVm0y+rHSuEZc2zzoa3sX7cB3tXSZbalCWXffnWeGRc5KNzmy/G2SXYW jXu6wAl42vMXmu/PDODei3rhDqHX0FSZBG/aoRxaKQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddriedugdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesrgdtre erreerjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhl vggurdgtohguvghsqeenucggtffrrghtthgvrhhnpeeffeduhfduudeikeekudfghfdugf eljefgkeeghfdvieekledvvdejheetgeetgeenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsg gprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id BC06715A0092; Wed, 24 Jul 2024 10:15:05 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-582-g5a02f8850-fm-20240719.002-g5a02f885 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Message-ID: In-Reply-To: <138f79e3-20cb-441f-8899-bdf40ef0868e@app.fastmail.com> 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> <138f79e3-20cb-441f-8899-bdf40ef0868e@app.fastmail.com> Date: Wed, 24 Jul 2024 16:14:45 +0200 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Lazy Objects Content-Type: multipart/alternative; boundary=7934739205364a7187314f2ffd2b9155 From: rob@bottled.codes ("Rob Landers") --7934739205364a7187314f2ffd2b9155 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: >>=20 >> >> Otherwise, I'm quite looking forward to this. >> > >> > =F0=9F=A4=9E >>=20 >> Another thought that occurred to me. Given how lightweight it *looks= * to be (may not actually be, but looks it), how much overhead would the= re be to having a compiled DI container that is lazy by default? Just m= ake everything lazy with a fairly standard initializer or factory, unles= s a specific case says you shouldn't. That way you can use optional dep= endencies in a constructor pretty much at will with no overhead of needi= ng to create a chain of dependencies as a result. >>=20 >> Would that be a bad idea for some reason, or would it actually work? >>=20 >> (This doesn't really affect my vote, more just a thought that came up= .) >>=20 >> --Larry Garfield >>=20 >=20 > I'm not convinced a DI container is possible at all with this implemen= tation, see "surprising behaviors." >=20 > When you are building a DI container, you usually have *absolutely no = idea* what a user will return from a proxy. At most, you might know they= are returning SomeInterface or SomeBaseClass, but the user might return= MyFancyClass that implements the interface or base class, which isn't a= llowed via this implementation. The type must be exactly the same or a p= arent class: >=20 >> the factory of a lazy proxy is allowed to return an instance of the s= ame class as the proxy, or of a parent class. >>=20 >> Returning an instance of a sub-class is not allowed >=20 > =E2=80=94 Rob Sorry, misspoke: > what a user will return from a proxy. should be "what a user will return from a factory." =E2=80=94 Rob --7934739205364a7187314f2ffd2b9155 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=

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, Nico= las Grekas wrote:

>> Otherwise, I'm q= uite 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 cont= ainer that is lazy by default?  Just make everything lazy with a fa= irly standard initializer or factory, unless a specific case says you sh= ouldn't.  That way you can use optional dependencies in a construct= or pretty much at will with no overhead of needing to create a chain of = dependencies as a result.

Would that be a b= ad idea for some reason, or would it actually work?

(This doesn't really affect my vote, more just a thought that c= ame up.)

--Larry Garfield

I'm not convinced a DI container= is possible at all with this implementation, see "surprising behaviors.= "

When you are building a DI container, you= usually have absolutely no idea what a user will return fro= m a proxy. At most, you might know they are returning SomeInterface or S= omeBaseClass, but the user might return MyFancyClass that implements the= interface or base class, which isn't allowed via this implementation. T= he type must be exactly the same or a parent class:

the factory of a lazy proxy is allowe= d to return an instance of the same class as the proxy, or of a parent c= lass.

Returning an instance of a sub-class = is not allowed

=E2=80=94 Rob

Sorry, m= isspoke:

what a u= ser will return from a proxy.

= should be "what a user will return from a factory."

=
=E2=80=94 Rob
--7934739205364a7187314f2ffd2b9155--