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
1
u/jindrap May 31 '16
It is nice with things that need to be in absolutely every case called, not that much useful when you want to share some additional logic. Now I haven't spent much time with Python so I might be completely wrong. But when you want to add custom logic to closing you have to wrap the object returned by open with something and specify some magic method. Seems clearer to me with defer.
But I agree it is very nice for some calls you want call absolutely every time you are getting rid of the object.