Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94486 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39578 invoked from network); 12 Jul 2016 08:38:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2016 08:38:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:37033] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 15/07-17655-49CA4875 for ; Tue, 12 Jul 2016 04:38:45 -0400 Received: by mail-wm0-f43.google.com with SMTP id i5so15633993wmg.0 for ; Tue, 12 Jul 2016 01:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=jXOL/U0e8+yCIw9Bc75v/aZ4hSqsRR3jVErZ2HcoRfM=; b=Q17ifWcWMaF/OD0tDh9EfC9VViPwBWy/Fm64ASQTmMYjCKtjjYUJSC6HKaXx5N76ov cSbW0jcwSxqcIJQw3fu/cjyG6y5yVOmRulDz+uJ0nMJNsCAnyMu6jZhd55J8WLeLx2AX rNPl0LufxzbPxgXyGMR6lFCBU5E5xOsZXUZoKN6Tug7gsyFoX8BKCHoK1jw9PaHZbxEB CMQ9UAVU4Q3xTPKzhgggF2yOq0V1yP95rycTBHXhQpP5dxNds1o8LgpFluDUTQtGhLH5 Wg+X4QWEr3GwBQqmewoQgNtRlTufCKMarLF5TYLBJynpLskturOAt9ywlkF8LLFJ4Mqh EKuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:references:from:to:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=jXOL/U0e8+yCIw9Bc75v/aZ4hSqsRR3jVErZ2HcoRfM=; b=ci5VAhZW0fZVsXNm0bOKLT1ANlv+LIGRjl1idlEQ5DiwZ1/w44HGI9b/tgGh0YKi34 Jx5ScTjd59UbChHYVu7oWQDTgnrnwwZLcHCOdBWB4T9kefBH8b0LvWQY9DirFNp/LKaV +5dYJzupETw53kr1Y3WP5WQSDAKImkPVMkla29RXxOCoCYOiwL+kwom9rkDuUhm9oABJ eTwGnvHSt3RTC/cPepw/RTX2piL/TjnA8F8pgyL6IwBUfuToAmL/Vb3NmxA4BUnX6Fyz TRRgIXqiEWVuiITjaZ10oQaW1LAaSOUXRb28AYD0twthTA9cTY0JXVUGaG4GAUZ9VNCO ytCQ== X-Gm-Message-State: ALyK8tLiAZaRVnUlT0bw5rfX7ORVCjKs5a3z7OI7PtTlnqa3gt13hvXYGiOC14hteQxgkg== X-Received: by 10.28.226.85 with SMTP id z82mr8004646wmg.101.1468312721740; Tue, 12 Jul 2016 01:38:41 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id n26sm2412864wmi.3.2016.07.12.01.38.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2016 01:38:41 -0700 (PDT) References: <86455a1e-eb57-1f30-9016-ac70c9f30bdd@gmail.com> To: PHP Internals List Message-ID: <33e06ab7-ec7b-0cc0-d724-ede441df6c89@gmail.com> Date: Tue, 12 Jul 2016 09:36:53 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Cascade Operator (was Re: [PHP-DEV] Proposal for php7 class method return) From: rowan.collins@gmail.com (Rowan Collins) On 12/07/2016 00:14, Jesse Schalken wrote: > If so, some consideration should be made as to which syntax is preferred > to solve this problem generally for both setting properties and calling > methods. > > I prefer the "obj { .. }" syntax because it mirrors object literals in > JSON/JavaScript, object initializers in C# and C/C++ and Haskell record > syntax, is particularly concise when nested to create large trees of > objects, and avoids the noise of "->>" on each line. All the examples you've given for that syntax are for initialisation, and I'm not sure how readable it would be for the general "do several things in a row" case: $counter { count(), count(), count(), count() } Thinking about it, this becomes something more like a "with" keyword: with ( $counter ) { count(); count(); count(); count(); } If with(){} could be used as an expression, you'd get something remarkably close to your initialiser example: $this->setBlah( with ( Blah::create(4) ) { foo = $foo; baz = with ( new Baz() ) { markFixed(); label = "Hello"; }; setBot(9); } ); I'm not sure if this is a good thing or not - with() statements exist in a few languages, with varying degrees of acceptance. I don't remember seeing one used as an expression like that before, though. There's a definite awkwardness of what to put on the left side of property assignments too... with ( new Foo ) { var = 1 } with ( new Foo ) { $var = 1 } with ( new Foo ) { ->var = 1 } Overall, it's an interesting idea, but the details are fiddly, and the gains marginal, IMO. Regards, -- Rowan Collins [IMSoP]