Stanislav Malyshev wrote:
IA>>Most common solution people choose to emulate exceptions often ends up being
IA>>recursive functions, those as well know in many instances result in crashes.

Eh? Only case I know when recursion may result in crash is if it's endless recursion (or recursion for all effective purposes can be considered endless - like one 100M functions deep). Do you know more cases?

A recursive function, takes a mere 13087 iterations to result in a crash and this is a very basic example.
$i = 0;
function a() { global $i; echo ++$i."\n"; a(); }
a();

A more complex function could take as little as 1k iterations.

IA>>Most PHP (internal or external) code does not use exceptions, just saying
IA>>"use exceptions" may work in Java, but certainly not in PHP.

Well, 100% of existing PHP code doesn't use goto either, so your argument is not working.

Ok, so you propose that people start using exceptions for OO and procedural code just because they are "there"? One major problem with an exception, is that once it is thrown you cannot go back to portions of code found within the exception block. This is why in many situations they are not practical for anything but fatal errors.

Ilia

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to