Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94481 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5490 invoked from network); 11 Jul 2016 21:20:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jul 2016 21:20:47 -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.50 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.50 mail-wm0-f50.google.com Received: from [74.125.82.50] ([74.125.82.50:36009] helo=mail-wm0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/C3-17655-EAD04875 for ; Mon, 11 Jul 2016 17:20:47 -0400 Received: by mail-wm0-f50.google.com with SMTP id f126so105950657wma.1 for ; Mon, 11 Jul 2016 14:20:46 -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=jBK6hdRqi7LgDSMas8a0gSNhQa6llUS9ZVeeKOOMh6E=; b=qYiHHGrKXql1VGWf4ntZaCtXoPSl/vN+UFzT09C5w+k5vfR09Y0QlbwQ7knn0gQoqT IOx3Vo2utkhZh2uhSzdr5eILJMMBzgEKIDiNSp+2J2Bl1c2hDlqQ8HE8S9rbCXwQACOt I0vWKjuebfse+5J7CKqO8huvrEtECP0F3d4nWgBjpxY+mwqonp6rhgI4L6Z8r1ZsM547 fKFDT1EaUm9OLClHZpQzbiboqH/hHFkXH8nYtBv1tpEvZVxrpR9cVryWvuRXzHMkYea7 QZLKrLFaem3eTL1BY999YeQXlZVo6db4gIzYFiXzdb2RAQRDYjFsbtpfjOyGnodQjUYT bugw== 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=jBK6hdRqi7LgDSMas8a0gSNhQa6llUS9ZVeeKOOMh6E=; b=luMLeJgHZ6dCfscgOyQjFFd/qbV3n/pqelMjKQC55/bEbpFba7SbDWsvtI73Av6zhO qU/DdUVMUJjrbsbDtcjiMCkSEfU8/Orrlh+5WpB+EoWTkmfS6nvSmNarr+eQOJvFyJNi afNaeqLT7O6DN44giDvdTIpkaoPDjwJTRko8aojHYDN7q3H6Z6aH6Egt9Xm6x1gmOT28 v5wWXbHyu4GyYgK+qFDURgjzLcHobGuN6BMWT/Bs9cD2Eld4kc4OT/ybgBDGBkbPth8s bqgxEXM7CnigYggbgHHe88DogBjc4WYVsk9qcSpf5zFeccfOBc4pd86o+zWSu4uQMkud 87lA== X-Gm-Message-State: ALyK8tJWrzPgLFMymk7eIk6As82NXMuJ0ozIlt/M2WfTUqlTTtxlJA/p8XvTgg6Fr4hEvQ== X-Received: by 10.28.137.68 with SMTP id l65mr20089212wmd.64.1468272043928; Mon, 11 Jul 2016 14:20:43 -0700 (PDT) Received: from [192.168.1.191] ([2.25.96.65]) by smtp.googlemail.com with ESMTPSA id e16sm2123551wma.12.2016.07.11.14.20.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2016 14:20:43 -0700 (PDT) References: To: PHP Internals List Message-ID: <23bdff6e-9ad7-1044-d9c3-e27b37c7d8f1@gmail.com> Date: Mon, 11 Jul 2016 22:20:39 +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] Proposal for php7 class method return From: rowan.collins@gmail.com (Rowan Collins) On 11/07/2016 21:17, Marco Pivetta wrote: > On 11 July 2016 at 22:15, Rowan Collins > wrote: > > Again, it's just different syntax for doing things we can already do. > > > Spot on! Plus it's something arguably considered a bad idea. I don't > think that adding language features for this sort of thing is useful. > Maybe it's even just harmful. Looking through the reasons given in your blog post, most of them don't really apply with a dedicated operator, because they're about the *contract*, and a cascade operator is only useful when the contract is to return something *other* than the current object. Specifically, it relies on the assumption that the method is not returning a new instance. To adapt one of your examples: $counter->count(); $counter->count(); $counter->count(); $counter->count(); echo $counter->getCount(); // This relies on count() mutating the current object, probably the contract is to return void The same thing, with ->> as a cascade operator: echo $counter ->>count() ->>count() ->>count() ->>count() ->getCount(); Or perhaps for clarity, pull the echo separately: $counter ->>count() ->>count() ->>count() ->>count(); echo $counter->getCount(); The cascade operator is a tool to use *instead of* a fluent interface, not *with* it, and it solves a lot of the problems you outlined - $counter here can be mocked, wrapped, substituted for different implementations, etc, because the ->> operator makes no more assumptions than the code was already making. Regards, -- Rowan Collins [IMSoP]