Re: Announcing RFC 'Anonymous Catches'

From: Date: Wed, 26 Jun 2013 06:50:54 +0000
Subject: Re: Announcing RFC 'Anonymous Catches'
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
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


Thread (10 messages)

« previous php.internals (#67845) next »