On 26 juni 2013 at 08:50:55, Patrick ALLAERT ([email protected]) wrote:
2013/6/25 Nikita Popov <[email protected]>:
> but I'm against the generic catch{} statement.
I'm sharing Nikita's opinion, with the difference of a bit more
enthusiasm on leaving off the variable as it could make it more
obvious that there is no intention in using the variable, and that no
memory should be kept for it. This might be better than doing:
try {
[...]
} catch (Exception $ignore) {
unset($ignore);
}
[...]
However, I see other cases where a variable is technically required
but not used:
abstract class AbstractPrinter {
abstract public function print($message);
}
class Printer extends AbstractPrinter {
public function print($message) {
echo $message;
}
}
class BlackholePrinter extends AbstractPrinter {
public function print($message) {
}
}
In the previous example, $message is not "used" in
BlackholePrinter::print() (as well as in AbstractPrinter::print()).
How do you intend to make that consistent with: catch(Exception) ?
Patrick
Your inheritance example is something that I do not have a good solution for (I
don't think there is one) but with Exceptions it's different, because there the
solution is obvious, unambiguous and expected.
That it also happens to be easy to implement is good to know, it means that the
effects of this change are totally obvious (because only ONE opcode has to be
changed, so there is only an effect on this ONE opcode, other code is not
affected in any way, that's good to know).
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php