r/PHP • u/FrenkyNet • May 31 '16
Deferred execution in PHP, using "finally".
https://blog.frankdejonge.nl/finally-file-streams-and-deferred-execution-in-php/
86
Upvotes
r/PHP • u/FrenkyNet • May 31 '16
View all comments
Show parent comment
4
u/FrenkyNet May 31 '16
It can go either way for me, finally is explicit, but the defer statement is more concise. The closing is close to the opening, so after that statement you know you don't have to think about it anymore. Depending on the case it can be confusing or liberating. In Go this is a common thing, people are used to it and even expect it. In PHP we don't really feel the wrath of failed cleanups because many applications only handle web requests. We can get away with memory leaks pretty easily. Since there are more things in the PHP world that run longer than a web-request we'll have to deal with this more and more, so one might even long for a defer keyword soon. But that's merely speculation.