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: