Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109115 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 64441 invoked from network); 17 Mar 2020 23:11:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Mar 2020 23:11:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AD72218077F for ; Tue, 17 Mar 2020 14:33:51 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 17 Mar 2020 14:33:51 -0700 (PDT) Received: by mail-vk1-f169.google.com with SMTP id k63so6466198vka.7 for ; Tue, 17 Mar 2020 14:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uzMj9joCFVKdsw+KfoIp1Zo9GBIagfRSWLDhsWeXE9o=; b=JGpGJIrG+IGp/1fIJRivGqx+AwT0k5R4kliIoU3rIbdgY8CjG4K+W4e/K7hA6ZqYJh 0Cx+wH8kjNaObdwl49uVLYMXj/H1b1alukTdWBseLKlAJcWP9/GSAVJR8dHsrIWQBdlp 4K9OEPnAl2ornRp2jmh7sp+SBeAS6+qvB853SIwqjYoxWWOXLAM+5aL3j+xEXMdjzj0R RL4rMv+O+yDeXb0MEbvW8IHSgmXhJ/vbOFJB6yqHpWssWXVZKEeIG5qAnTOG9GdSs1SK d2CRXVsEGCZR7ihsUCiBnW7rXj7cRD76Fh5b9dtERHXe3SvnXSOqyb+6h4wgNQwqOx6/ T97A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uzMj9joCFVKdsw+KfoIp1Zo9GBIagfRSWLDhsWeXE9o=; b=UsHi7QjBdxOq1tXlU3x6esixvRw6Iqs66aNK/qpMPI1ys2s79QFRlpBzFYCVAkkpjP x9TusPthov9jBP+OKFO2MZrZLuHEwucLOUyDQ8RwvzSi0TGbgEeP4ytEuSAFN18HM6LZ RebCyHa0SXeWEVNFCqbn9SFkkJpUPMOnzpxeMMs0AIw9ccSAYwfxO8UAtrdhn9X2Xx4V zuKvCv3DK6poFVlYx2hRUBvuN4MMfyyid4drRs+C40Fwd1dl2Z2cCvPlxTx1Q3tlgFr9 +veqIZxHCFMYQAu/88F6Qpvz+iK6BRkYV3az3h/mJjq4aabq64FRFtbUPpp/+C13q9Bh XrEg== X-Gm-Message-State: ANhLgQ23zA9keitpMTa0lfT3tr755ZlAIvTqJ7WooEjnItqrsI1bcOXL B0HLKYAuIU4nyHIjtSmZBplD942JlOytY4qHZix8DoXd X-Google-Smtp-Source: ADFU+vsO7wP1dkJz2TqpchvSaRQGOvbc5ViwvmdnzBDE/XsMrHKZ7W/b1GAI1Tgr/50MeSdjkrxfDXqQPkMd5Vlikq4= X-Received: by 2002:a1f:bf95:: with SMTP id p143mr1166594vkf.29.1584480830575; Tue, 17 Mar 2020 14:33:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 17 Mar 2020 17:33:38 -0400 Message-ID: To: Jakob Givoni Cc: php internals Content-Type: multipart/alternative; boundary="0000000000000f56bc05a113b168" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment From: matthewmatthew@gmail.com (Matthew Brown) --0000000000000f56bc05a113b168 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I don't think it's conflicting _if you insist on brackets_ after the new expression. PHP Parser grammar for "new" expressions is T_NEW class_name_reference ctor_arguments If you allowed the shorter syntax, ctor_arguments would allow an object_properties entry. I'm sure Nikita could clarify, though. On Mon, 16 Mar 2020 at 21:13, Jakob Givoni wrote: > On Mon, Mar 16, 2020 at 9:10 AM Matthew Brown > wrote: > > I love the idea! > Thanks Matthew! > > > The syntax for new objects looks a little verbose =E2=80=93 would it be= possible > to use > > > > $foo =3D new Foo()[ > > property1 =3D "hello", > > property2 =3D 5, > > ]; > The short answer: I don't think so. > > This is not possible (though it's arguably 'nicer'): > > new Foo()->doSomething(); // syntax error, unexpected '->' > > Not sure why, but it's necessary to wrap the instantiation in brackets: > > (new Foo())->doSomething(); // Ok > > If someone can explain why, it would be enlightening! > > Furthermore, dropping the arrow would create conflicting syntax with > array access: > > $foo[1]; // Array access, give me the element with index 1, can be > used on objects as well > $foo[a =3D 1]; // Property assignment... ??? > > I'll update the RFC to reflect your proposal. > > Thank you, > Jakob > --0000000000000f56bc05a113b168--