Re: [PHP-DEV] Continued try blocks

2013-05-07 Thread Seva Lapsha
The feature exists in Python: http://stackoverflow.com/questions/574730/python-how-to-ignore-an-exception-and-proceed, in Ruby: http://stackoverflow.com/questions/5089802/which-is-the-shortest-way-to-silently-ignore-a-ruby-exception. Just saying. On Wed, May 1, 2013 at 4:46 AM, Patrick ALLAERT

Re: [PHP-DEV] Continued try blocks

2013-05-07 Thread Stas Malyshev
Hi! The feature exists in Python: http://stackoverflow.com/questions/574730/python-how-to-ignore-an-exception-and-proceed, I don't think it does what is proposed - except/pass just catches an exception and does nothing, it does not return in the place where exception was thrown down the

Re: [PHP-DEV] Continued try blocks

2013-05-01 Thread Patrick ALLAERT
2013/4/30 Pierre Joye pierre@gmail.com: hi, On Tue, Apr 30, 2013 at 7:54 PM, Stas Malyshev smalys...@sugarcrm.com wrote: You may have a lib/object/chunk of code which raises exceptions, because its developer thought some error is not recoverable; but when you use it, you don't want to

Re: [PHP-DEV] Continued try blocks

2013-04-30 Thread Amaury Bouchard
2013/4/29 Stas Malyshev smalys...@sugarcrm.com I agree. If your code can handle the problem, it should not throw. If it throws, the control should not go back there, since the code already gave up and declared it can not continue doing whatever it was doing. Exceptions are meant to handle

Re: [PHP-DEV] Continued try blocks

2013-04-30 Thread Stas Malyshev
Hi! It's a point of view, not something the language should enforce. It is a point of view that any proper language should enforce. Languages always enforce certain style, certain ideas and certain paradigm - be it computer languages or natural languages. You can decide from now on in your

Re: [PHP-DEV] Continued try blocks

2013-04-30 Thread Pierre Joye
hi, On Tue, Apr 30, 2013 at 7:54 PM, Stas Malyshev smalys...@sugarcrm.com wrote: You may have a lib/object/chunk of code which raises exceptions, because its developer thought some error is not recoverable; but when you use it, you don't want to break your program's execution. That's why

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Ralph Schindler
I think we should look at swapping out the parser for something more context aware before we start adding more generic keywords that have global symbol ramifications and has name BC implications. There is some code (lots?) out there that has: class SomeClass { public function resume() {

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Johannes Schlüter
On Fri, 2013-04-26 at 16:41 +0200, Julien Pauli wrote: Hello internals, I had an idea recently with a friend, about a feature try-catch blocks could use. Let me just write an example, you will quickly understand the idea : *?php* * * *try {* * foo();* * bar();* * baz();* *}

Re: AW: [PHP-DEV] Continued try blocks

2013-04-29 Thread Johannes Schlüter
On Sat, 2013-04-27 at 19:46 +0100, Robert Stoll wrote: I agree with Amaury. Although, it is rather smelly code to use try/catch as control flow instrument, in some situations it is clearer to do it this way. I think the new construct would be especially useful if one just wants to log

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Lazare Inepologlou
2013/4/28 Julien Pauli jpa...@php.net On Sat, Apr 27, 2013 at 3:56 PM, Amaury Bouchard ama...@amaury.net wrote: 2013/4/27 Ferenc Kovacs tyr...@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

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Lars Strojny
Hi Julien, I'm still on the fence, not sure if it isn’t too opaque. Am 26.04.2013 um 16:41 schrieb Julien Pauli jpa...@php.net: [...] One question regarding scoping: does the next statement inherit the scope of the catch block like this? try { $user = $repository-findById(123);

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Johannes Schlüter
On Mon, 2013-04-29 at 08:25 +0200, Lars Strojny wrote: Hi Julien, I'm still on the fence, not sure if it isn’t too opaque. Am 26.04.2013 um 16:41 schrieb Julien Pauli jpa...@php.net: [...] One question regarding scoping: does the next statement inherit the scope of the catch block

[PHP-DEV] Re: [lists.php] Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread ALeX
HI, I also really don't like it. if you have a try/catch within a for, will it continue the try or for? (or have I to use continue 2 to reach the for) At least use another keyword to make it more clear that you don't want to continue a loop at the beginning but a catch statement after the

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Ralph Schindler
So, in this example, if, say, bar() throws a SomeException , the code would then resume and execute baz() after the catch block. Just presenting the idea here, no RFC actually , I'm collecting thoughts and notices. It seems like you want application specific flow control (caller specific)

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Camilo Sperberg
On Apr 28, 2013, at 17:27, Julien Pauli jpa...@php.net wrote: On Sat, Apr 27, 2013 at 3:56 PM, Amaury Bouchard ama...@amaury.net wrote: 2013/4/27 Ferenc Kovacs tyr...@gmail.com please don't reuse the continue keyword for it. There are a bunch of code out there where which uses

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Camilo Sperberg
On Apr 29, 2013, at 09:25, Amaury Bouchard ama...@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

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Stas Malyshev
Hi! this has quite a few issues and feels like abusing exceptions for regular control flow. The primary issue is that throw is a terminating operation. A I agree. If your code can handle the problem, it should not throw. If it throws, the control should not go back there, since the code

Re: [PHP-DEV] Continued try blocks

2013-04-29 Thread Amaury Bouchard
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 unrea...@gmail.com

Re: [PHP-DEV] Continued try blocks

2013-04-28 Thread Julien Pauli
On Sat, Apr 27, 2013 at 3:56 PM, Amaury Bouchard ama...@amaury.net wrote: 2013/4/27 Ferenc Kovacs tyr...@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

Re: [PHP-DEV] Continued try blocks

2013-04-27 Thread Ferenc Kovacs
As Julien said, there is a BC break, when a try/catch block is written inside a loop. But I think it's not a major usage, and it's a minor inconvenient. Yeah, and catching and discarding exceptions also possible, albeit a minor inconvinience. I don't have a strong opinion on this

Re: [PHP-DEV] Continued try blocks

2013-04-27 Thread Amaury Bouchard
2013/4/27 Ferenc Kovacs tyr...@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

Re: [PHP-DEV] Continued try blocks

2013-04-27 Thread Daniel Macedo
Sorry but I disagree, I think you're approaching try-catch wrong. You shouldn't have a try-catch that *can* continue on the next line after the throw. What you should do is have decoupled code that handles _their own exceptions_ nicely and either cleans up after itself else it rethrows the

Re: [PHP-DEV] Continued try blocks

2013-04-27 Thread Amaury Bouchard
2013/4/27 Daniel Macedo admac...@gmail.com Sorry but I disagree, I think you're approaching try-catch wrong. You shouldn't have a try-catch that *can* continue on the next line after the throw. What you should do is have decoupled code that handles _their own exceptions_ nicely and either

AW: [PHP-DEV] Continued try blocks

2013-04-27 Thread Robert Stoll
] Continued try blocks 2013/4/27 Daniel Macedo admac...@gmail.com Sorry but I disagree, I think you're approaching try-catch wrong. You shouldn't have a try-catch that *can* continue on the next line after the throw. What you should do is have decoupled code that handles _their own exceptions_

[PHP-DEV] Continued try blocks

2013-04-26 Thread Julien Pauli
Hello internals, I had an idea recently with a friend, about a feature try-catch blocks could use. Let me just write an example, you will quickly understand the idea : *?php* * * *try {* * foo();* * bar();* * baz();* *} catch (SomeException $e) {* *dosomestuff();* *continue; /*

Re: [PHP-DEV] Continued try blocks

2013-04-26 Thread Александр Бобров
Sounds interesting. And what about the second attempt passing the try block without goto? 2013/4/26 Julien Pauli jpa...@php.net Hello internals, I had an idea recently with a friend, about a feature try-catch blocks could use. Let me just write an example, you will quickly understand the

Re: [PHP-DEV] Continued try blocks

2013-04-26 Thread Lazare Inepologlou
2013/4/26 Julien Pauli jpa...@php.net Hello internals, I had an idea recently with a friend, about a feature try-catch blocks could use. Let me just write an example, you will quickly understand the idea : *?php* * * *try {* * foo();* * bar();* * baz();* *} catch

Re: [PHP-DEV] Continued try blocks

2013-04-26 Thread Patrick Schaaf
On Friday 26 April 2013 16:41:17 Julien Pauli wrote: *try {* * foo();* * bar();* * baz();* *} catch (SomeException $e) {* *dosomestuff();* *continue; /* Here is the feature, go back to try block */* *} catch (Exception $e) {* *dosomething();* *}* ... So, in this

Re: [PHP-DEV] Continued try blocks

2013-04-26 Thread Amaury Bouchard
I will answer, as the idea came from Pierrick Charron and I :-) Sometimes, you call functions (or methods) and you know they can throw some exceptions. But you don't want to stop all computations just because one of them raised an exception. Maybe you just want to log it, and go to the next

Re: [PHP-DEV] Continued try blocks

2013-04-26 Thread Kalle Sommer Nielsen
Hi 2013/4/26 Lazare Inepologlou linep...@gmail.com: This seems like a BC break: for ( ; ; ) { try { ... } catch (Exception $e) { continue; } } With the proposed syntax, continue will no longer refer to the for loop. Well, at the moment continue is assigned to only usage

Re: [PHP-DEV] Continued try blocks

2013-04-26 Thread Andreas Heigl
Am 26.04.13 16:41, schrieb Julien Pauli: Hello internals, I had an idea recently with a friend, about a feature try-catch blocks could use. Let me just write an example, you will quickly understand the idea : *?php* * * *try {* * foo();* * bar();* * baz();* *} catch

AW: [PHP-DEV] Continued try blocks

2013-04-26 Thread Robert Stoll
2013 20:15 An: Julien Pauli Cc: PHP Internals Betreff: Re: [PHP-DEV] Continued try blocks Am 26.04.13 16:41, schrieb Julien Pauli: Hello internals, I had an idea recently with a friend, about a feature try-catch blocks could use. Let me just write an example, you will quickly understand

Re: [PHP-DEV] Continued try blocks

2013-04-26 Thread Amaury Bouchard
2013/4/26 Andreas Heigl andr...@heigl.org try { $foo = $bar-getObject(); $foo-doSomething() } catch(Exception $e) { continue // Or whatever shall be used } When $bar-getObject throws an Exception no $foo is set. So the next line will result in a PHP Fatal error: Call to a