Ask a Question related to PHP Development, Design and Development.
-
Cristiano Duarte #1
[PHP-DEV] Re: try/catch/FINALLY
Please, ignore this:
exit> IMHO I think that an implementation start would be hooking the functionAnd read this instead:> at the engine..
IMHO I think that an implementation start would be hooking the exit of the
try statement even if its normal or has an exception thrown...
Best regards,
Cristiano Duarte
"Cristiano Duarte" <cunha17@uol.com.br> escreveu na mensagem
news:20030806001540.7978.qmail@pb1.pair.com...up> Hi all,
>
> I know there was a lot of discussion about try/catch, but I will bring ita> again:
>
> What about finally ?
>
> I know someone posted that finally isn't necessary since PHP destroy all
> variables and releases all resources at the end of the script. But if the
> script is a PHP-GTK application or a standalone server aplication (like
> CORBA)?
>
> Finally is very useful in situations where you must be certain that some
> piece of code will be executed no matter what happens (a normal execution,exit> return statement or an exception).
>
> IMHO I think that an implementation start would be hooking the function> at the engine..
>
> Cristiano Duarte
>
>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
Cristiano Duarte Guest
-
[PHP-DEV] finally again
Hi internals ! I really need an opinion about this. Cristiano Duarte -- PHP Internals - PHP Runtime Development Mailing List To... -
The problem with Try Catch Finally...
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the... -
Question: Try,Catch,Finally
I usually put my declarations for db connections, datasets, datareaders, etc... above the Try portion. Inside the Try is where I open my... -
Re[2]: [PHP-DEV] try/catch/FINALLY
Hello Marcus, Wednesday, August 6, 2003, 1:14:10 PM, you wrote: CD>> What about finally ? MB> There's absolute no need for finally: MB>... -
[PHP-DEV] try/catch/FINALLY
Hi all, I know there was a lot of discussion about try/catch, but I will bring it up again: What about finally ? I know someone posted that... -
Marcus Börger #2
Re: [PHP-DEV] try/catch/FINALLY
Hello Cristiano,
Wednesday, August 6, 2003, 2:15:39 AM, you wrote:
CD> Hi all,
CD> I know there was a lot of discussion about try/catch, but I will bring it up
CD> again:
CD> What about finally ?
There's absolute no need for finally:
try {
}
catch (...) {
}
// here's you're finally code
--
Best regards,
Marcus mailto:helly@php.net
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
Marcus Börger Guest
-
Timm Friebe #3
Re: [PHP-DEV] try/catch/FINALLY
On Wed, 2003-08-06 at 09:14, Marcus Börger wrote:
[...]> Hello Cristiano,Well, consider:> There's absolute no need for finally:
>
> try {
> }
> catch (...) {
> }
> // here's you're finally code
function foo() {
try {
// ...
} catch (Exception $e) {
// ...handle it...
return false;
} finally {
// ...clean up...
}
// ...continue doing whatever...
return true;
}
The cleanup code is always to be executed, the method should of course
not continue in case an exception was caught.
OK, I could write:
function foo() {
try {
// ...
} catch (Exception $e) {
// ...handle it...
}
// ...clean up ...
if ($e) return false;
// ...continue doing whatever...
return true;
}
so all it boils down to is, I guess, syntactic sugar.
Evil programming language sourcecode below:)
----------------------------------------------------------------------------
thekid@thekid:~ > cat FinallyTest.java
class FinallyTest {
public static void main(String[] args) {
boolean success= FinallyTest.test(args.length > 0);
System.out.println("Success? " + success);
}
public static boolean test(boolean dothrow) {
try {
if (dothrow) {
throw new Exception("Test");
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
System.out.println("<<< In finally >>>");
}
System.out.println("OK");
return true;
}
}
thekid@thekid:~ > CLASSPATH="." java FinallyTest
<<< In finally >>>
OK
Success? true
thekid@thekid:~ > CLASSPATH="." java FinallyTest 1
java.lang.Exception: Test
at FinallyTest.test(FinallyTest.java:10)
at FinallyTest.main(FinallyTest.java:3)
<<< In finally >>>
Success? false
- Timm
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
Timm Friebe Guest
-
Wez Furlong #4
Re: [PHP-DEV] try/catch/FINALLY
The most important thing missing from this is that you cannot rethrow the
exception from the point where you suggest to place the finally code :-)
--Wez.
> There's absolute no need for finally:
>
> try {
> }
> catch (...) {
> }
> // here's you're finally code
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
Wez Furlong Guest
-
Simeon Koptelov #5
Re: [PHP-DEV] try/catch/FINALLY
Hello Cristiano,
Wednesday, August 6, 2003, 6:15:39 AM, you wrote:
It would be much better if user will have to put method's throws in
method's declaration imho( see my reply to Marcus ).
--
Best regards,
Simeon mailto:xi@newmail.ru
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
Simeon Koptelov Guest
-
Jeff Moore #6
Re: [PHP-DEV] try/catch/FINALLY
On Wednesday, August 6, 2003, at 03:14 AM, Marcus B=F6rger wrote:
PHP doesn't necessarily control every resources you might want to=20> There's absolute no need for finally:
deallocate.
mysql_query('LOCK ...');
try {
... do stuff
} finally {
mysql_query('UNLOCK...');
}
... do more stuff=
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
Jeff Moore Guest



Reply With Quote

