Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93069 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18928 invoked from network); 4 May 2016 14:31:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2016 14:31:39 -0000 Authentication-Results: pb1.pair.com header.from=jesseschalken@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jesseschalken@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.175 as permitted sender) X-PHP-List-Original-Sender: jesseschalken@gmail.com X-Host-Fingerprint: 209.85.213.175 mail-ig0-f175.google.com Received: from [209.85.213.175] ([209.85.213.175:38631] helo=mail-ig0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/30-16256-AC70A275 for ; Wed, 04 May 2016 10:31:39 -0400 Received: by mail-ig0-f175.google.com with SMTP id m9so49431461ige.1 for ; Wed, 04 May 2016 07:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=2TwgahQRtkVYPN9WE7VCRH+ap3eVBAKPNZIY97Arrws=; b=s+UNqA1sbkcbAku9mKDmxhZ0FIQ4PCyxi+ql5XwUw0kgWlTEHBT3tUUzk3wtqgabbA 60lgXSR975MlKhUUJHuEiUFdwmEGr0F+zkTGyHUTV/6RgPYC+W/r2cfJDYUTL0NggYBA Vg08QWWek2Pd3/vJb+NOCRlR0tTAEi/k0atVnJe+ZF4bYEoehjsrSVsYAU7CzywzWBM4 fMNxa5U3DcixiEOhNkhj3ZcSsm+CDu9m/8AhnvEaHXCbWeAzdUUHwAp15i5cuIphVvki jh2rPVvZXYkBCaSWJrByqu/ns1iETiNljizFMw22FP4LWOUjJzhl1x5wnQDI3grBYSlk qxbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=2TwgahQRtkVYPN9WE7VCRH+ap3eVBAKPNZIY97Arrws=; b=O9OfNApo0yFG3YazEFTeSXzPPF6IGM6IvqfD2twMe16HjeZ675aCZmsG0c/WihRLhB 17hdUtMLmlg79QUvEfBnhvv3X0MWNhsKnUrWlysfMyMNz71BNHJK5FhsAy05R+M5j/0i mtxQTdsLONrx8dyfua+EpjRs30YTK+Soc5Bq0+CvDWpJHXPV55H+S74PpNRBtAteA3Kt 7yvBfG4VhuS9DHiFLSID7L/b+euAX0yK6uK6NuGC9loERk1wTl/GVLx9WBATWf6Mmaac QzsJto8z18NydA3wb0ulhmEBkUK7zvWBESI86fU9jQ4figkOpb300bRe9lJbOv19g6dx xbAQ== X-Gm-Message-State: AOPr4FWQlrvUZFfUKtXE7XRtsoTcNvatMpTo6GRtkqUjsng81KpcME6oLQEM+jj/+qUXAE0DH2K1kDD8hg0OhQ== MIME-Version: 1.0 X-Received: by 10.50.28.113 with SMTP id a17mr11017166igh.44.1462372294714; Wed, 04 May 2016 07:31:34 -0700 (PDT) Sender: jesseschalken@gmail.com Received: by 10.79.139.3 with HTTP; Wed, 4 May 2016 07:31:34 -0700 (PDT) Received: by 10.79.139.3 with HTTP; Wed, 4 May 2016 07:31:34 -0700 (PDT) In-Reply-To: References: <5723F2AE.2020806@garfieldtech.com> Date: Thu, 5 May 2016 00:31:34 +1000 X-Google-Sender-Auth: ruMUUD3N_EERP303PLy70n8iw7I Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: multipart/alternative; boundary=089e01538ac827ed9c053205157c Subject: Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal From: me@jesseschalken.com (Jesse Schalken) --089e01538ac827ed9c053205157c Content-Type: text/plain; charset=UTF-8 On 4 May 2016 10:41 pm, "Rowan Collins" wrote: > > > You could either think of this as "setting lots of variables": > > new Foo { $bar = 1, $baz = 2 } > > or you could think of it as "an object literal like an array literal": > > new Foo { 'bar' => 1, 'baz' => 2 } > I think a $ is only necessary to disambiguate, ie between variable and constant. It isn't necessary as a prefix for properties when it is unambiguous that the thing is a property. Eg property access is ->foo, not ->$foo. I don't think the string literal syntax is appropriate for classes/structs/records which have a defined, static structure. You would use that when you're talking about a hash table/associative array/map/dict, for which the key is often an arbitrary expression. So I would go with plain property name without prefix. It certainly looks nicer in the context of annotations. > > And then we also need to think about sitting nicely with anonymous class syntax. Not to mention Joe's proposal for lexical scope: https://wiki.php.net/rfc/lexical-anon > AFAIK anonymous classes always start with "new class ..", so there would be no ambiguity. It would be an optional {...} part that follows a class instantiation, anonymous or not. > > For the record, I like the idea, if we can come up with a consistent plan for how these pieces of syntax will work together, and not paint ourselves into an ASCII-art hole... > It sounds like this conversation has been had before (but I'm not sure about instantiate-and-set-properties specifically), but nonetheless the problem remains and it's a common pain point for me and fellow devs. Annotations sound like the ideal time to address it since they also need to instantiate classes and set public properties in one expression. --089e01538ac827ed9c053205157c--