Re: [RFC] [Discussion] Retry functionality

From: Date: Mon, 19 Jun 2017 15:16:02 +0000
Subject: Re: [RFC] [Discussion] Retry functionality
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-99552@lists.php.net to get a copy of this message
Hey Sammy, From a language design perspective, this is syntactic sugar that brings a lot of cost for anyone working on optimisations. In most scenarios that I worked on, the retry functionality should always be written as following: try { $externalCollaborator->doSomething($with, $a, $lot, $of, $by, $val, $parameters); } catch (SomethingSomething $e) { $externalCollaborator->doSomething($with, $a, $lot, $of, $by, $val, $parameters); } The reason why it is extremely important to have an external collaborator is that logic wrapped in a retry *MUST* be tested for idempotence. Just imagine what could happen if a credit card payment was processed twice! That said, the above can be rewritten as following: retry( function () use ($externalCollaborator, $with, $a, $lot, $of, $by, $val, $parameters) { $externalCollaborator->doSomething($with, $a, $lot, $of, $by, $val, $parameters); }, [SomethingSomething::class], 1 ); Where the signature of retry is as following: function retry(callable $executedLogic, array $caughtExceptionTypes, int $maxRetries) { /* ... */ } This kind of approach is simpler to understand, to test, and doesn't include the "hidden GOTO semantics" that are proposed in this patch, and that would make SSA optimizations quite hard to perform. Given the above, I'm sadly going to vote "NO" on this proposal. Greets, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Mon, Jun 19, 2017 at 3:55 PM, Sammy Kaye Powers <me@sammyk.me> wrote: > Hello internals! > > The RFC that proposes adding retry functionality to the > try/catch/finally block is now officially "under > discussion". > > https://wiki.php.net/rfc/retry-keyword > > Voting will open on Monday, July 3rd, 2017 @ 9 am CDT. > > Voting will close on Monday, July 17th, 2017 @ 9 am CDT. > > Discuss amongst yourselves. :) > > Thanks, > Sammy Kaye Powers > sammyk.me > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#99552) next »