Re: Continued try blocks

From: Date: Mon, 29 Apr 2013 07:36:00 +0000
Subject: Re: Continued try blocks
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-67196@lists.php.net to get a copy of this message
On Apr 29, 2013, at 09:25, Amaury Bouchard <amaury@amaury.net> wrote: > Why not. But it will come in addition to "resume", not instead of it. > Then: > - "resume" => continue execution just after the point where the exception was > raised. > - "restart" => restart the whole try block. > > I don't understand the meaning of your "rollback". > > > 2013/4/29 Camilo Sperberg <unreal4u@gmail.com> > > On Apr 28, 2013, at 17:27, Julien Pauli <jpauli@php.net> wrote: > > > On Sat, Apr 27, 2013 at 3:56 PM, Amaury Bouchard <amaury@amaury.net> wrote: > > > >> 2013/4/27 Ferenc Kovacs <tyra3l@gmail.com> > >> > >>> please don't reuse the continue keyword for it. > >>> > >>> There are a bunch of code out there where which uses exceptions in a loop > >>> context. > >>> For example you have a retry counter decremented in a loop and you catch > >>> the exceptions and retry until the retry limit is reached. > >>> > >> Fair enough. We can use "resume". > >> > > > > "continue" is just a keyword (syntactic sugar) we sure can change, I like > > "resume" yes :-) > > > > Julien.Pauli > > And how about a restart instead of resume? I have used try catch blocks as a type of > transactional block, so I think it would be nice if I could restart the entire block instead of > resuming from the last point where it failed: > > $blue = 'blue'; > try { > $data = a($blue); > b($data); // This throws the dataIntegrityException > c(); > } catch (dataIntegrityException $e) { > $blue = 'is the new red'; > restart; // executes a(), b() and c() again > } catch (Exception $e) { > rollback(); > } > > Greetings. > It was just to denote the nature of a transaction block, nothing important ;)

« previous php.internals (#67196) next »