agc's avatar

agc

agc

Member since

70

Total Reputation

2

Total Arguments

8

Total Votes for Arguments

Arguments and votes

2

I never understood the limit of one statement in the short arrow function syntax.

This seems to fix it and put arrow functions back on the level of the standard anonymous function.

Share:
Read the RFC: Short Closures 2.0 agc avatar
agc
voted yes
1

First, it's really mostly syntactic sugar, adding cognitive load for no added Language-level feature. Besides, it's not clear how easy it would be to step over this code with a debugger.

Second, the argument that the equivalent nested function calls is much less readable, is sound but I think a developer should write neither. Both nested functions calls and chained function calls are hard to live-debug and hard to read, and most of the time in my experience are also an unnecessary micro-optimization.

Third, I think this specific operator "|>" isn't easy to type. The "->" member operator was a mistake of the past, we are stuck with it, don't make another one.

Share:
Read the RFC: The Pipe Operator agc avatar
agc
voted no
19

Still hard to read. No extra benefits.

The only clean solution is to use scalar types (string, int, float, boolean) and arrays like objects:

$result = "Hello World"->htmlentities()->split()->map(strtoupper(...))->filter(fn($v) => $v != 'O');

Chain, clean oop, readable, IDE hint, no value parameter, no prefixes and an opportunity to correct the functions inconsistency. It could works beside functions: strtoupper($name) and $name->toUpper().

Share:
Read the RFC: The Pipe Operator hricer avatar
hricer
voted no
35

I see no immediate benefit of the proposed solution over the userland implementations. The RFC mentions a shopping cart example, but I don't think that's cleaner than using league/pipeline or Laravel's pipeline.

It's a bit messy for the simpler examples as well.

Share:
Read the RFC: The Pipe Operator ju5t avatar
ju5t
voted no
18

It's almost as messy as putting all the functions into each other.

Share:
Read the RFC: The Pipe Operator t avatar
t
voted no
7

Would avoid me having to use dodgy looking code such as fn($item) => [$this->doSomething($item), $this->doSomethingElse($item)]

Share:
Read the RFC: Short Closures 2.0 jw avatar
jw
voted yes
81

We spend a lot more time reading code than writing it. The elegance of short closure combined with the convenience of variable scope usage has already shown to be a game changer on Typescript and there doesn’t seem to be any technical issue with having it on PHP.

Share:
Read the RFC: Short Closures 2.0 marco avatar
marco
voted yes
121

At least once a week, I throw away an array_map because it ended up looking too bloated and go with a classic foreach instead. Short Closures 2.0 without the use(...) block would've solved this problem, just 2 votes...

Share:
Read the RFC: Short Closures 2.0 davi avatar
davi
voted yes
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!