Re: [PHP-DEV] Pipe Operator v2

2017-01-26 Thread Levi Morrison
On Thu, Jan 26, 2017 at 1:56 PM, Rasmus Schultz wrote: > Besides, I mean, I'm sure this has occurred to everyone, right? > > https://gist.github.com/mindplay-dk/4ef61fd5c0a35e5aa8fc699febb86487 > > I personally find that this new syntax you're proposing requires a lot of >

Re: [PHP-DEV] Pipe Operator v2

2017-01-26 Thread Rasmus Schultz
Besides, I mean, I'm sure this has occurred to everyone, right? https://gist.github.com/mindplay-dk/4ef61fd5c0a35e5aa8fc699febb86487 I personally find that this new syntax you're proposing requires a lot of parsing. I mean, whenever you see substr() or array_map() etc. you're intuitively

Re: [PHP-DEV] Pipe Operator v2

2017-01-24 Thread Stephen Reay
As a userland developer I feel $$ (or some variation starting with $) is reasonably natural - it's a variation on a regular variable. Sent from my iPhone > On 25 Jan 2017, at 03:53, Levi Morrison wrote: > >> On Tue, Jan 24, 2017 at 12:25 PM, Rasmus Schultz

Re: [PHP-DEV] Pipe Operator v2

2017-01-24 Thread Levi Morrison
On Tue, Jan 24, 2017 at 12:25 PM, Rasmus Schultz wrote: > Isn't `_` more generally used as a "discard" placeholder in most languages? > > At least in Swift, Go, Scala, Dart and C# (starting with v7) I think? > > I don't recall having seen it mean "fill in the blank". In what

Re: [PHP-DEV] Pipe Operator v2

2017-01-24 Thread Rasmus Schultz
Isn't `_` more generally used as a "discard" placeholder in most languages? At least in Swift, Go, Scala, Dart and C# (starting with v7) I think? I don't recall having seen it mean "fill in the blank". In what languages? On Fri, Jan 20, 2017 at 4:26 PM, Levi Morrison wrote: >

Re: [PHP-DEV] Pipe Operator v2

2017-01-20 Thread Levi Morrison
Oops, sorry for an email that just quotes others; mis-clicked send. > Last, a cosmetic suggestion : replace '$$' with '$<' (more explicit as > 'input data', imo). If we aren't going to use `$$` I'd like to use `_` or `__` which read similar to "fill in the blank" and has precedence in other

Re: [PHP-DEV] Pipe Operator v2

2017-01-20 Thread Levi Morrison
On Fri, Jan 20, 2017 at 3:53 AM, François Laupretre wrote: > Le 19/01/2017 à 22:53, Levi Morrison a écrit : >> >> On Thu, Jan 19, 2017 at 11:12 AM, François Laupretre >> wrote: >>> >>> Le 19/01/2017 à 13:54, Levi Morrison a écrit : The `|>`

Re: [PHP-DEV] Pipe Operator v2

2017-01-20 Thread Levi Morrison
On mobile, sorry for top posting. Multiple $$ means the resulting closure will accept multple arguments. I'm definitely against dropping the ($$) on the right hand side because it would use non standard symbol lookup rules. $x = trim; This normally will look up a constant, and then apply

Re: [PHP-DEV] Pipe Operator v2

2017-01-20 Thread François Laupretre
Le 19/01/2017 à 22:53, Levi Morrison a écrit : On Thu, Jan 19, 2017 at 11:12 AM, François Laupretre wrote: Le 19/01/2017 à 13:54, Levi Morrison a écrit : The `|>` symbol would be the piping operator with these semantics: 1. Evaluate the left-hand side. 2.

Re: [PHP-DEV] Pipe Operator v2

2017-01-20 Thread Rowan Collins
On 20 January 2017 00:59:59 GMT+00:00, Levi Morrison wrote: > >I empathize that you don't like string-name callables (I really don't >like them either) but this RFC helps avoid the string if you want to. >Consider > >// without my proposal: >array_map('trim', $input) > >

Re: [PHP-DEV] Pipe Operator v2

2017-01-19 Thread Levi Morrison
On Thu, Jan 19, 2017 at 4:55 PM, Ryan Pallas wrote: > On Thu, Jan 19, 2017 at 4:08 PM, Rowan Collins > wrote: >> >> >> On 19/01/2017 22:17, Ryan Pallas wrote: >> >>> >>> When you say assert the right hand side is callable, does that mean to >>> call

Re: [PHP-DEV] Pipe Operator v2

2017-01-19 Thread Ryan Pallas
On Thu, Jan 19, 2017 at 4:08 PM, Rowan Collins wrote: > > > On 19/01/2017 22:17, Ryan Pallas wrote: > >> >> When you say assert the right hand side is callable, does that mean to >> call an object method, you would do [$obj, 'method']? What about >> functions, >> is it

Re: [PHP-DEV] Pipe Operator v2

2017-01-19 Thread Rowan Collins
On Thu, Jan 19, 2017 at 5:54 AM, Levi Morrison wrote: I've talked to you about this RFC off-list, but I figured I should mention it on-list as well. I think we should make `|>` and `$$` two independent operators that work well together (rather than only together). Firstly,

Re: [PHP-DEV] Pipe Operator v2

2017-01-19 Thread Ryan Pallas
On Thu, Jan 19, 2017 at 5:54 AM, Levi Morrison wrote: > On Wed, Jul 20, 2016 at 5:42 PM, Sara Golemon wrote: > > With the branching of 7.1, and after some reflection on the previous > > feedback, I'd like to reopen discussion of the Pipe Operator RFC > >

Re: [PHP-DEV] Pipe Operator v2

2017-01-19 Thread Levi Morrison
On Thu, Jan 19, 2017 at 11:12 AM, François Laupretre wrote: > Le 19/01/2017 à 13:54, Levi Morrison a écrit : >> >> The `|>` symbol would be the piping operator with these semantics: >> 1. Evaluate the left-hand side. >> 2. Evaluate the right-hand side. Assert that

Re: [PHP-DEV] Pipe Operator v2

2017-01-19 Thread François Laupretre
Le 19/01/2017 à 13:54, Levi Morrison a écrit : The `|>` symbol would be the piping operator with these semantics: 1. Evaluate the left-hand side. 2. Evaluate the right-hand side. Assert that the result is callable. 3. Pass the result from 1. as the single argument to 2. May I

Re: [PHP-DEV] Pipe Operator v2

2017-01-19 Thread Levi Morrison
On Wed, Jul 20, 2016 at 5:42 PM, Sara Golemon wrote: > With the branching of 7.1, and after some reflection on the previous > feedback, I'd like to reopen discussion of the Pipe Operator RFC > https://wiki.php.net/rfc/pipe-operator which I had previously put on > hold. I've

Re: [PHP-DEV] Pipe Operator v2

2017-01-19 Thread Yasuo Ohgaki
On Mon, Jul 25, 2016 at 11:52 PM, Björn Larsson wrote: > Den 2016-07-22 kl. 17:05, skrev David Rodrigues: > > It's possible to use the tilde ~ easyly on keyboards? >> For on BR/ABNT2 is easy. So maybe use ~> as operator could be fine, >> instead of the triangle |>, and

Re: [PHP-DEV] Pipe Operator v2

2017-01-18 Thread Joe Watkins
Morning Sara, This has generated some very decent discussion. It seems like time to put this to a vote, could you maybe find some time to do that please ? Alternatively, if there are outstanding issues that are stopping this going to a vote, could we know what they are, and maybe your plan to

Re: [PHP-DEV] Pipe Operator v2

2016-07-25 Thread Björn Larsson
Den 2016-07-22 kl. 17:05, skrev David Rodrigues: It's possible to use the tilde ~ easyly on keyboards? For on BR/ABNT2 is easy. So maybe use ~> as operator could be fine, instead of the triangle |>, and linear sounds good too, like: $string~>escape($$)~>dump($$); It's used currently on PHP for

Re: [PHP-DEV] Pipe Operator v2

2016-07-23 Thread Sara Golemon
On Sat, Jul 23, 2016 at 1:11 PM, Stanislav Malyshev wrote: > There is a lot of ways in which PHP needs improvement, but right now I > think inventing more syntax tricks in not one of them. Even in syntax > department, PHP has areas where we could use improvement (e.g. to name

Re: [PHP-DEV] Pipe Operator v2

2016-07-23 Thread Sara Golemon
On Sat, Jul 23, 2016 at 8:15 AM, Rowan Collins wrote: > Glad it makes sense. :) I realise "return $$" would have to have some > special handling, but it would feel more natural to me. I guess the only > concern is what happens when a pipeline has a return terminal and is

Re: [PHP-DEV] Pipe Operator v2

2016-07-23 Thread Sara Golemon
On Sat, Jul 23, 2016 at 4:15 AM, Rasmus Schultz wrote: > FWIW, I've read the manual page for the Hack page, and the RFC, a couple of > times now, and I simply don't understand it. > Perhaps the documentation needs clarifying then. > Are most PHP developers going to understand

Re: [PHP-DEV] Pipe Operator v2

2016-07-23 Thread Stanislav Malyshev
Hi! >> $x = loadConfig(); >> $x = buildDic($x); >> $x = getApp($x) >> $x = getRouter($x) >> $x = getDispatcher($x, $request) >> $x = dispatchBusinessLogic($x, $request, new Response()) >> $x = renderResponse($x) >> $x = buildPsr7Response($x) >> $response =emit($x); >> > > I agree the example

Re: [PHP-DEV] Pipe Operator v2

2016-07-23 Thread Rowan Collins
On 22/07/2016 06:52, Sara Golemon wrote: Ah! I understand your point now. Indeed, in terms of code-scan, there's something of a whiplash effect going on. Now I understand the motivation behind $> assignment and/or using a terminal like `return $$` at the end. Adding in support for some

Re: [PHP-DEV] Pipe Operator v2

2016-07-23 Thread Rowan Collins
On 23/07/2016 12:15, Rasmus Schultz wrote: I mean, maybe it's just me, because I'm familiar with the cascade operator from other languages - but it seems simpler, more intuitive, easier to pick up, and appears to solve most of the same problems? If so, perhaps it would be right to consider the

Re: [PHP-DEV] Pipe Operator v2

2016-07-23 Thread Rasmus Schultz
FWIW, I've read the manual page for the Hack page, and the RFC, a couple of times now, and I simply don't understand it. Are most PHP developers going to understand this feature, the meaning of $$, and when/how to use this? Are they going to be able to read code written in this way? To your

Re: [PHP-DEV] Pipe Operator v2

2016-07-22 Thread Larry Garfield
On Wed, Jul 20, 2016, at 11:37 PM, Sara Golemon wrote: > > However, the introduction discusses fluent chained methods of objects, and > > states " This RFC aims to improve code readability by bringing fluent > > expressions to functional and OOP libraries not originally designed for the > >

Re: [PHP-DEV] Pipe Operator v2

2016-07-22 Thread David Rodrigues
It's possible to use the tilde ~ easyly on keyboards? For on BR/ABNT2 is easy. So maybe use ~> as operator could be fine, instead of the triangle |>, and linear sounds good too, like: $string~>escape($$)~>dump($$); It's used currently on PHP for a bitwise operation (not), so I think that the

Re: [PHP-DEV] Pipe Operator v2

2016-07-21 Thread Sara Golemon
On Thu, Jul 21, 2016 at 2:56 PM, Rowan Collins wrote: > On 21/07/2016 22:28, Sara Golemon wrote: >> >> Are you picturing the return statement returning from the current >> function? Or "returning" from the current pipe chain? >> >> I think you mean the former, in which

Re: [PHP-DEV] Pipe Operator v2

2016-07-21 Thread Rowan Collins
On 21/07/2016 22:28, Sara Golemon wrote: Are you picturing the return statement returning from the current function? Or "returning" from the current pipe chain? I think you mean the former, in which case I'd ask how that'd better/worse than: return foo() |> bar($$); I do indeed mean

Re: [PHP-DEV] Pipe Operator v2

2016-07-21 Thread Sara Golemon
On Thu, Jul 21, 2016 at 6:59 AM, Rowan Collins wrote: > On 21/07/2016 00:42, Sara Golemon wrote: >> >> With the branching of 7.1, and after some reflection on the previous >> feedback, I'd like to reopen discussion of the Pipe Operator RFC >>

Re: [PHP-DEV] Pipe Operator v2

2016-07-21 Thread Rowan Collins
On 21/07/2016 00:42, Sara Golemon wrote: With the branching of 7.1, and after some reflection on the previous feedback, I'd like to reopen discussion of the Pipe Operator RFC https://wiki.php.net/rfc/pipe-operator which I had previously put on hold. I've changed much of the argument wording of

Re: [PHP-DEV] Pipe Operator v2

2016-07-21 Thread 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 [...]

Re: [PHP-DEV] Pipe Operator v2

2016-07-21 Thread David Rodrigues
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 --> can be too long, but can make more sense or continuing,

Re: [PHP-DEV] Pipe Operator v2

2016-07-21 Thread Stefan Neufeind
On 21.07.2016 06:37, Sara Golemon wrote: > On Wed, Jul 20, 2016 at 8:50 PM, Larry Garfield > wrote: [...] > return $this->loadConfig() > |> $arg->useConfig($$) > |> $this->loadUser($$) > |> array_merge($$, $this->userDefaults); > > But the PSR7 example is

Re: [PHP-DEV] Pipe Operator v2

2016-07-20 Thread Sara Golemon
On Wed, Jul 20, 2016 at 8:50 PM, Larry Garfield wrote: > I am still generally in favor of this proposal. Especially when dealing > with nested array functions this operator would be a big boon to > readability. > That's honestly my 90% use-case as well. array_merge and

Re: [PHP-DEV] Pipe Operator v2

2016-07-20 Thread Sara Golemon
> On Thu, Jul 21, 2016 at 9:05 AM, Thomas Bley wrote: > to me this code is perfectly readable and static code analysis is only > complaining about missing semicolons at the end of the lines and short > variable names: > > $x = loadConfig(); > $x = buildDic($x); > $x =

Re: [PHP-DEV] Pipe Operator v2

2016-07-20 Thread Larry Garfield
On 07/20/2016 07:42 PM, Sara Golemon wrote: With the branching of 7.1, and after some reflection on the previous feedback, I'd like to reopen discussion of the Pipe Operator RFC https://wiki.php.net/rfc/pipe-operator which I had previously put on hold. I've changed much of the argument wording

Re: [PHP-DEV] Pipe Operator v2

2016-07-20 Thread Yasuo Ohgaki
Hi Thomas, On Thu, Jul 21, 2016 at 9:05 AM, Thomas Bley wrote: > to me this code is perfectly readable and static code analysis is only > complaining about missing semicolons at the end of the lines and short > variable names: > > $x = loadConfig(); > $x = buildDic($x); >

Re: [PHP-DEV] Pipe Operator v2

2016-07-20 Thread Thomas Bley
to me this code is perfectly readable and static code analysis is only complaining about missing semicolons at the end of the lines and short variable names: $x = loadConfig(); $x = buildDic($x); $x = getApp($x) $x = getRouter($x) $x = getDispatcher($x, $request) $x = dispatchBusinessLogic($x,

[PHP-DEV] Pipe Operator v2

2016-07-20 Thread Sara Golemon
With the branching of 7.1, and after some reflection on the previous feedback, I'd like to reopen discussion of the Pipe Operator RFC https://wiki.php.net/rfc/pipe-operator which I had previously put on hold. I've changed much of the argument wording of the proposal, but not the substantive