Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment

This is only part of a thread. view whole thread
  109059
March 16, 2020 14:26 cschneid@cschneid.com (Christian Schneider)
Am 16.03.2020 um 12:48 schrieb Jakob Givoni <jakob@givoni.dk>:
> I'm opening up my new RFC for discussion: > > https://wiki.php.net/rfc/compact-object-property-assignment > - A pragmatic approach to object literals > > Let me know what you think!
Sorry to say but the syntax look very un-PHP-like. [] suggests an array but then is uses literals and = instead of 'strings'/$vars and => which looks wrong to my PHP eye. Apart from that it feels weird that you have an object where you want to initialise so many properties manually instead of through some sort of constructor. Is it more of a record than an object? I'm not sure if I that is a pattern I would want to encourage. My $.02, - Chris
  109085
March 17, 2020 01:22 jakob@givoni.dk (Jakob Givoni)
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.