Short Closures 2.0

Read the RFC
98
368 yes
65 no

This RFC proposes a way to have multi-line short closures — closures that don't need explicit use statements, but can still have multiple lines and a return statement.

Click the bar to cast your vote!
85%
15%
1

This makes code much more readable and beautiful. I think the last line can be returned without having the return keyword like ruby and some other languages.

Share:
mokhosh avatar
mokhosh
voted yes
1

it just a good next step towards clean and readable code.

Share:
gertvdb avatar
gertvdb
voted yes
1
Share:
undjike avatar
undjike
voted yes
1

It will make php more consistent

Share:
bronek89 avatar
bronek89
voted yes
1

The point of short closure is to be one instruction only, plus you can already have the body of a short closure on multiple lines.

Regular closure can do multiple lines and instruction already.

To me this is a tiny syntactic sugar that is really unecessary.

Share:
florentpoujol avatar
florentpoujol
voted no
1

would make the code more readable, instead of the need to pass multiple parameters through the use()

Share:
andreas avatar
andreas
voted yes
1

I thought short closures 1.0 was a step in the right direction, I would like to see this continued.

Share:
sam-moffat avatar
sam-moffat
voted yes
1

seems obvious

Share:
letssurf avatar
letssurf
voted yes
1

Not a fan of closures.

These things can be useful in specific cases, but as i've seen someone else mention aswel shouldn't be used carelessly. In my opinion closures, especially when scattered throughout a codebase, make code hard to read.

Hiding scope makes this even more dangerous. It shouldn't always be about "faster to type", "less lines" or "doesnt require me to think". We should make sure everyone is able to work together on a codebase, we can do that by being explicit.

Please don't make javascript 2.0.

Share:
vslokker avatar
vslokker
voted no
1

Small but nice QoL improvement

Share:
sandermuller avatar
sandermuller
voted yes
1

I always hoped it would work this way

Share:
harasimowiczkamil avatar
harasimowiczkamil
voted yes
1

I like the idea of auto-capture!

Share:
oleg-andreyev avatar
oleg-andreyev
voted yes
1

Makes them more useful!

Share:
johnluxor avatar
johnluxor
voted yes
1

usable

Share:
brilliant-almazov avatar
brilliant-almazov
voted yes
1

The function scope must be respected in all cases. Function without scopes and default "use all variables" would be confusing. If you have nested closures, where the scope ends. Closures would be a nightmare like JavaScript functions.

Share:
anibalsanchez avatar
anibalsanchez
voted no
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!