Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:94613
Return-Path: <rowan.collins@gmail.com>
Mailing-List: contact internals-help@lists.php.net; run by ezmlm
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 79751 invoked from network); 21 Jul 2016 13:35:58 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
  by localhost with SMTP; 21 Jul 2016 13:35:58 -0000
Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass
Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass
Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.50 as permitted sender)
X-PHP-List-Original-Sender: rowan.collins@gmail.com
X-Host-Fingerprint: 209.85.215.50 mail-lf0-f50.google.com  
Received: from [209.85.215.50] ([209.85.215.50:35335] helo=mail-lf0-f50.google.com)
	by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
	id 0F/F1-52781-DBFC0975 for <internals@lists.php.net>; Thu, 21 Jul 2016 09:35:57 -0400
Received: by mail-lf0-f50.google.com with SMTP id f93so62214707lfi.2
        for <internals@lists.php.net>; Thu, 21 Jul 2016 06:35:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-transfer-encoding;
        bh=xtp4+JLybAWxakrYvPY5FY1OUfYEbcZyR9gqkDXb8e4=;
        b=Gqv1xA3pybFAzOg9Cu2Mmj+VF43/e8izK6eXcHCmpMNe6F7IBoVDDnMX51WXNHekRQ
         CJLbdXMfr6NYzZurUZwIaoCc6tMIKQRxNCLo4jYAomv68I3jYi9OmTg4pPvKBa9oVSdg
         VNHHxipeRFzG044XDRPIcmCT9wsxqPfqPbfX+EzDimC6h42EmJkR4QqL0OgfcdvldrKA
         UWkhXuw0llwy953PORG3hRxO6RMMJwDcOi54UwDXCuFjrCVKJNViXIYIXWzHMd1q8Csc
         G1VUmK4nW5pGw3EH0t9y68ciZVtjO7fxMeJIE7evB6nrPHAdSSI4kDjdr2uKfpY3xUa6
         MB/Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-transfer-encoding;
        bh=xtp4+JLybAWxakrYvPY5FY1OUfYEbcZyR9gqkDXb8e4=;
        b=jYYheDzBx9fxU2yTVmfmaUE1MMxBpzDdguf9IOMoAi5i9qgJPI9eCjpR1RirBebrT+
         rEb9qPUYrnAVjj0EkdiIbZI1PzsKcaYdBwfHuet4UsLz8MeUYQyFCu7OLYEaJm+9fUbN
         VWEiSRwRPWr201x1tsBONWuvh18b9sEkzI1i8R7eYQYoTHGiZ9j0d4kP9bD9l5i5TCve
         hpY+ThiAA4npqDGjbKrrWedPQMRvk04ITw68Znzf28BigU5zsEx7PLUzZppvt5217ONZ
         2DF8cphf/9m9TITd4nGtf2kgoRQhvXkDk1u/oh1+ZZKSH0hLlpoQytaTthqkuzCaru24
         g66w==
X-Gm-Message-State: ALyK8tJ4QMqxrAC28436tEFiQWgexj84O67nXCtvvxxTgreHexjxTOr3FAZzFDS4sBne5g==
X-Received: by 10.25.23.210 with SMTP id 79mr25857031lfx.200.1469108153991;
        Thu, 21 Jul 2016 06:35:53 -0700 (PDT)
Received: from [192.168.0.98] ([93.188.182.58])
        by smtp.gmail.com with ESMTPSA id c12sm1802550lfc.40.2016.07.21.06.35.52
        for <internals@lists.php.net>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 21 Jul 2016 06:35:53 -0700 (PDT)
To: internals@lists.php.net
References: <CAESVnVoBrtfWGF-Be+uXWwLNO3=JzuLBXyhW0Dpo-NvoskofQw@mail.gmail.com>
 <5786dd74-8a32-eb16-aec1-77b12d5af1c1@garfieldtech.com>
 <CAEsg9X1F1Dfo_7FGgDHhGxA1ypsUE1qEbMkezTOVtJvgY+RcJA@mail.gmail.com>
Message-ID: <597235c0-ebf5-d6b7-4c33-995a45f649a7@gmail.com>
Date: Thu, 21 Jul 2016 14:34:15 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101
 Thunderbird/45.2.0
MIME-Version: 1.0
In-Reply-To: <CAEsg9X1F1Dfo_7FGgDHhGxA1ypsUE1qEbMkezTOVtJvgY+RcJA@mail.gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Subject: Re: [PHP-DEV] Pipe Operator v2
From: rowan.collins@gmail.com (Rowan Collins)

On 21/07/2016 13:39, David Rodrigues wrote:
> This is a great idea in general, but I think that this kind of
> operator is not the ideal (expect for $$ that seems very good).
>
> Some possibilities to think about:
>
> |> (as suggested) seems strange and not very clear, mainly in linear calls
[...]
> Should be think about the linear readability too, for instance:
> $object->a()->b()->c() vs. $object|>a()|>b()|>c().

I think it's quite clear, personally, particularly if you just add a bit 
of whitespace:

$thing |> a($$) |> b($$) |> c($$)

The |> looks kind of like a triangle pointing to the next pipe.



> It can works to avoid matroska (as initial suggestion) but for objects too.
> PHP should identify if this operator is used over object or other type
> (that allows the use of $$).
> The problem is it can be confused: are you executing an object method
> or another function with the object?
> Like in: $clockObject |> setHour(12) |> is_string($$). 'is_string' is
> from Clock or PHP native function?

I think you may be confusing this with the other, somewhat 
complementary, proposal of a "method cascade" operator. Since this 
operator always takes the result of one expression as the input to the 
next, the equivalent for object methods already exists: ->

Your example wouldn't do anything much, because there's no $$ in 
setHour(12), but:

$clockObject -> setHour(12) |> is_string($$)

would be equivalent to:

is_string( $clockObject -> setHour(12) )


That said, if there's a possibility we'll have both features, we need to 
think about how the operators will look next to each other, and how easy 
it will be to pick the right one.

Regards,
-- 
Rowan Collins
[IMSoP]