rfc:retry-keyword

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:retry-keyword [2017/06/19 13:44] – More type-o's sammykrfc:retry-keyword [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== PHP RFC: Retry keyword in catch blocks ======+====== PHP RFC: Retry functionality ======
   * Version: 1.0   * Version: 1.0
   * Date: 2016-06-19   * Date: 2016-06-19
Line 135: Line 135:
 </code> </code>
  
-This is arguably the cleanest option for retrying but is blanketed with the negative stigma of using a ''goto''.+While this is arguably the cleanest option, it still requires the developer to define and manage label which over several refactors might gradually move further away from the top of the ''try'' lineThis implementation also makes it easy to accidentally execute any code after the label & before the ''try'' for each retry which is not entirely obvious at first glance. 
 + 
 +<code php> 
 +$maxTries = 5; 
 + 
 +retryTheThing: 
 + 
 +someCodeIDoNotWantToRetry(); 
 + 
 +try { 
 +    somethingSketchy(); 
 +} catch (RecoverableException $e) { 
 +    if (--$maxTries > 0) { 
 +        goto retryTheThing; 
 +    } 
 +    die('Tried a bunch but failed.'); 
 +
 +</code>
  
 ==== Use Retry ==== ==== Use Retry ====
Line 361: Line 378:
 ===== Proposed PHP Version ===== ===== Proposed PHP Version =====
  
-Next PHP 7.2.+Next PHP 7.3.
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
rfc/retry-keyword.1497879890.txt.gz · Last modified: 2017/09/22 13:28 (external edit)