Re: [RFC] [DISCUSSION] Compact Object Property Assignment
| From: | Jakob Givoni | Date: | Tue, 17 Mar 2020 01:22:40 +0000 |
| Subject: | Re: [RFC] [DISCUSSION] Compact Object Property Assignment | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109085@lists.php.net to get a copy of this message | ||
On Mon, Mar 16, 2020 at 9:26 AM Christian Schneider
<cschneid@cschneid.com> wrote:
> [] suggests an array but then is uses literals and = instead of 'strings'/$vars and
> => which looks wrong to my PHP eye.
That's ok, square brackets are usually related to arrays and what I
want is something similar to array literals.
The rest of the syntax is exactly the same as when you assign
properties on a object currently.
> you want to initialise so many properties manually instead of through some sort of constructor.
Yes, exactly. From the RFC:
"The purpose of this feature is to lighten the effort of populating
data structures, especially medium to large ones."
And as I say, since we don't have named parameters, this is a
pragmatic alternative.