Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124422 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 1A33A1A00B7 for ; Mon, 15 Jul 2024 06:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721025226; bh=DUbjv6n9bARO+tJHpmXrT2dLfACEUZoVdThUQprCgbI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=D9wOCBW/KYZjLGu1D8g9Z6xBnHbCN3Cw0DjKc+i841dSn11TXyTJkYUlvf6oov7oa SOhiHOkV1KVeJoTDQn71ntSXt/JytohQAILvvy87KIh37FQ+/NXsJQvgrdfCz2cksC uU6MVH8b3gSWONAfLkTSt2NFcAlf8Hm2j5+nhG1CGQQxQCseQiYLMNPLfuyl9LU2tC ntGEWGicazVtKEJjOUg5x44aKGke6wADJ+574HNI3DPVJVcf4owfH6iTTowNvtV7oO K7pb0pM1n65nZCH9MHnSuJY7TE8nV0+je3sZLLfjE++sxatkffEaoH8mR3ImF2T6Tb 86XSE3JOtByuQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 84DA818006E for ; Mon, 15 Jul 2024 06:33:45 +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=1.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLY,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-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 ; Mon, 15 Jul 2024 06:33:45 +0000 (UTC) Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2eea8ea8c06so56459351fa.2 for ; Sun, 14 Jul 2024 23:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721025135; x=1721629935; 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=YVIdJRdFyhWKfPX11hRBLysNYR8g5QIGuU3MZmt4Rpw=; b=dFCIjJuzVn3fP8vYFqvgjtiEY0rTigaFREIeXmtYWCywPh/xXyB37zLMHy7wc+w9vF 0UYot6qqmqBUxNZKT82kf3rcIAeVZhGGrpWtrwDF6EYBCKZzyqGJx+vu53ox3dCCs2eh S5GeDUH+ZwABpWOgXxtDoaVruzrd2u8gDLT0dsa55QdhGxtP9XTRcnMp07B6SiHM2x1c wDKgMHqbXwQw+kODtAy+zGHJMMg5fnrGzfodEUlO3OfQuQ+aZZ+RPh47zZHE/Zc6+4oR OJj4Ca2MpNTxMZ576RbAgPxzJ3LJJYJPVwXl7HgDuzlce2SYKOYRNLopJoiZU4E6Mzsq FGGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721025135; x=1721629935; 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=YVIdJRdFyhWKfPX11hRBLysNYR8g5QIGuU3MZmt4Rpw=; b=wlDJSTFjOdGpKz5Pf3c3WsRxSjn7RIHzX5loCZJbTcW+tU8DtojhDMw8TlOZCLGTwO Wfs2qg5SCQcwXGPbmPvuviqWpNqADVy1OUWj+dfboyuVNJCLjtFEHXQHOtJkhK3viRoL fNsSy6/pS33KZyKcoq4DoWR/bWAEwnNeSGO0WFfIRAhyoNC1jcgWN+jyLSSksm4S28sK lrXCFCgTF3tcjUSeh+Pl4OpvGpqgYARRF8Eggscd+IqqE3ivWiBNGBI91BRMc+P2zvdg 82qL077dX5X41OC5AQcnOhlk42bFBru5MMrGAxMZd6FtL39IIzMQMHK0w2T2TKucYtLd zA7Q== X-Forwarded-Encrypted: i=1; AJvYcCWCtL9LpyFkPgba/Ifcgz+0bwp79r8S2Z6jrbpEoiUsYV/WjEFOUW1+LRPvUNp0V47AQTobbvUt46JcxhFq1/9wxPQKl5OrMQ== X-Gm-Message-State: AOJu0Yzr2bj+KZMiaXnuRgI02qPCIK0Tm0HfLNWe8/fSwpVt5P3rvYdB Fqf5Upek8/Ib+at+bIKrnTglplGQCQppcifFU5aWBjoxbhRsMvx4eQ2tKPpwtHTIvQWEel3xyjc cUF0GClSGfvH21jA5bChtVoUF+8F5wA== X-Google-Smtp-Source: AGHT+IENIb157xA2Exl7SepUFZUtjO/AzhSFW4AdmcSZA1rrqacoIriESeiP4OwIdKzaXHgkREkyw6a9iDKddkwPyhA= X-Received: by 2002:a2e:9e99:0:b0:2ee:8c48:ffaf with SMTP id 38308e7fff4ca-2eeb31977a8mr110210511fa.47.1721025134414; Sun, 14 Jul 2024 23:32:14 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <1118bbcd-a7b4-47bf-bf35-1a36ab4628e1@bastelstu.be> <8fc1969d-5f21-400d-a3ae-aee5d741a81d@app.fastmail.com> In-Reply-To: Date: Mon, 15 Jul 2024 08:32:01 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Lazy Objects To: =?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?= Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000c952cf061d436311" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000c952cf061d436311 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le ven. 12 juil. 2024 =C3=A0 12:55, Benjamin Au=C3=9Fenhofer a =C3=A9crit : > > > Am 21.06.2024, 12:24:20 schrieb Nicolas Grekas < > nicolas.grekas+php@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 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 resetAsLazyProxy(object $object, callable >>>>> > $factory, int $options): void {} >>>>> > >>>>> > public function resetAsLazyGhost(object $object, callable >>>>> > $initializer, int $options): void {} >>>>> > >>>>> > public function initialize(object $object): object {} >>>>> > >>>>> > public function isInitialized(object $object): bool {} >>>>> > >>>>> > // existing methods >>>>> > } >>>>> > >>>>> > class ReflectionProperty >>>>> > { >>>>> > public function setRawValueWithoutInitialization(object $object= , >>>>> > mixed $value): void {} >>>>> > >>>>> > public function skipInitialization(object $object): void {} >>>>> > >>>>> > // existing methods >>>>> > } >>>>> > ``` >>>>> > >>>>> > Comments / rationale: >>>>> > - Adding methods on ReflectionClass instead of ReflectionObject is >>>>> > better from a performance point of view, as mentioned earlier >>>>> > - Keeping the word "Lazy" in method names is clearer, especially fo= r >>>>> > "newLazyProxy" as a the "Proxy" pattern has many uses-cases that ar= e >>>>> > not related to laziness. However we removed the word "Instance" to >>>>> > make the names shorter. >>>>> > - We have renamed "make" methods to "reset", following your feedbac= k >>>>> > about the word "make". It should better convey the behavior of thes= e >>>>> > methods, and clarify that it's modifying the object in-place as wel= l >>>>> > as resetting its state >>>>> > - setRawValueWithoutInitialization() has the same behavior as >>>>> > setRawValue() (from the hooks RFC), except it doesn't trigger >>>>> > initialization >>>>> > - Renamed $initializer to $factory for proxy methods >>>>> > >>>>> > WDYT? >>>>> > >>>>> > Best Regards, >>>>> > Arnaud >>>>> >>>>> Oh, that looks *so* much more self-explanatory and readable. I love >>>>> it. Thanks! (Looks like the RFC text hasn't been updated yet.) >>>>> >>>> >>>> Happy you like it so much! The text of the RFC is now up to date. Note >>>> that we renamed ReflectionProperty::skipInitialization() and >>>> setRawValueWithoutInitialization() to skipLazyInitialization() and >>>> setRawValueWithoutLazyInitialization() after we realized that >>>> ReflectionProperty already has an isInitialized() method for something >>>> quite different. >>>> >>>> While Arnaud works on moving the code to the updated API, are there >>>> more comments on this RFC before we consider opening the vote? >>>> >>> >>> Thank you for updating the API, the RFC is now much easier to grasp. >>> >>> >>> My few comments on the updated RFC: >>> >>> >>> 1 ) ReflectionClass API is already very large, adding methods should us= e >>> naming carefully to make sure that users identify them as belonging to = a >>> sub.feature (lazy objects) in particular, so i would prefer we rename s= ome >>> of the new methods to: >>> >>> >>> isInitialized =3D> isLazyObject (with inverted logic) >>> >>> initialize =3D> one of initializeLazyObject / initializeWhenLazy / >>> lazyInitialize - other methods in this RFC are already very outspoken, = so I >>> don=E2=80=99t mind being very specific here as well. >>> >>> >>> The reason is =E2=80=9Einitialized=E2=80=9C is such a generic word, bes= t not have API >>> users make assumptions about what this relates to (readonly, lazy, =E2= =80=A6) >>> >> >> I get this aspect, I'm fine with either option, dunno if anyone has a >> strong preference? >> Under this argument, mine is isLazyObject + initializeLazyObject. >> > > The RFC still has the isInitialized and initialize methods, lets go with > your suggestions isLazyObject, initializeLazyObject, and also maybe > markLazyObjectAsInitialized instead of markAsInitialized? > I've updated the RFC with these method names. I've a slight preference towards shorter names that don't contain the "lazy object" wording but I feel like the consensus might be to have the more explicit versions, so fine to me. --000000000000c952cf061d436311 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
Le=C2=A0ven. 12 juil. 2024 =C3=A0=C2= =A012:55, Benjamin Au=C3=9Fenhofer <kontakt@beberlei.de> a =C3=A9crit=C2=A0:


Am 21.06.2024, 12:24:20 schrieb N= icolas Grekas <nicolas.grekas+php@gmail.com>:
Hi Ben,

On Tue, Jun 18, 2024, at 5:45 PM, Arnaud Le Blanc wr= ote:
> Hi Larry,
>
> Following your feedback we propose to amend the API as follows:
>
> ```
> class ReflectionClass
> {
>=C2=A0 =C2=A0 =C2=A0public function newLazyProxy(callable $factory, int= $options): object {}
>
>=C2=A0 =C2=A0 =C2=A0public function newLazyGhost(callable $initializer,= int $options): object {}
>
>=C2=A0 =C2=A0 =C2=A0public function resetAsLazyProxy(object $object, ca= llable
> $factory, int $options): void {}
>
>=C2=A0 =C2=A0 =C2=A0public function resetAsLazyGhost(object $object, ca= llable
> $initializer, int $options): void {}
>
>=C2=A0 =C2=A0 =C2=A0public function initialize(object $object): object = {}
>
>=C2=A0 =C2=A0 =C2=A0public function isInitialized(object $object): bool= {}
>
>=C2=A0 =C2=A0 =C2=A0// existing methods
> }
>
> class ReflectionProperty
> {
>=C2=A0 =C2=A0 =C2=A0public function setRawValueWithoutInitialization(ob= ject $object,
> mixed $value): void {}
>
>=C2=A0 =C2=A0 =C2=A0public function skipInitialization(object $object):= void {}
>
>=C2=A0 =C2=A0 =C2=A0// existing methods
> }
> ```
>
> Comments / rationale:
> - Adding methods on ReflectionClass instead of ReflectionObject is
> better from a performance point of view, as mentioned earlier
> - Keeping the word "Lazy" in method names is clearer, especi= ally for
> "newLazyProxy" as a the "Proxy" pattern has many u= ses-cases that are
> not related to laziness. However we removed the word "Instance&qu= ot; to
> make the names shorter.
> - We have renamed "make" methods to "reset", follo= wing your feedback
> about the word "make". It should better convey the behavior = of these
> methods, and clarify that it's modifying the object in-place as we= ll
> as resetting its state
> - setRawValueWithoutInitialization() has the same behavior as
> setRawValue() (from the hooks RFC), except it doesn't trigger
> initialization
> - Renamed $initializer to $factory for proxy methods
>
> WDYT?
>
> Best Regards,
> Arnaud

Oh, that looks *so* much more self-explanatory and readable.=C2=A0 I love i= t.=C2=A0 Thanks!=C2=A0 (Looks like the RFC text hasn't been updated yet= .)

Happy you like it so much! The text = of the RFC is now up to date. Note that we renamed ReflectionProperty::skip= Initialization() and setRawValueWithoutInitialization() to skipLazyInitiali= zation() and setRawValueWithoutLazyInitialization() after we realized that = ReflectionProperty already has an isInitialized() method for something quit= e different.

While Arnaud works on moving the code= to the updated API, are there more comments on this RFC before we consider= opening the vote?

Thank you for updating the API, the RF= C is now much easier to grasp.


=

My few comments on the upda= ted RFC:


=

1 ) ReflectionClass API is = already very large, adding methods should use naming carefully to make sure= that users identify them as belonging to a sub.feature (lazy objects) in p= articular, so i would prefer we rename some of the new methods to:


=

=C2=A0isInitialized =3D>= isLazyObject (with inverted logic)

initialize =3D> one of i= nitializeLazyObject / initializeWhenLazy / lazyInitialize - other methods i= n this RFC are already very outspoken, so I don=E2=80=99t mind being very s= pecific here as well.


=

The reason is =E2=80=9Einit= ialized=E2=80=9C is such a generic word, best not have API users make assum= ptions about what this relates to (readonly, lazy, =E2=80=A6)


I get this aspect, I'm fine w= ith either option, dunno if anyone has a strong preference?
Under= this argument, mine is isLazyObject + initializeLazyObject.

The RFC still has the isInitialized and = initialize methods, lets go with your suggestions isLazyObject, initializeL= azyObject, and also maybe markLazyObjectAsInitialized instead of markAsInit= ialized?


I've= updated the RFC with these method names. I've a slight preference towa= rds shorter names that don't contain the "lazy object" wordin= g but I feel like the consensus might be to have the more explicit versions= , so fine to me.


--000000000000c952cf061d436311--