On Tue, Feb 09, 2010 at 11:38:42PM +0100, Rene Veerman wrote:

> Well, i've thought of a few ways to allow localized overriding of
> values returned by functions in case of an error.
> I have yet to figure out what the exact advantages are of this
> code-standard, but the overhead seems acceptable and i recon this,
> when done, will beat the "trigger_error()-try-catch" paradigm.
> I'd like to hear your comments.
> // imo unsafe & prone to fatalities:
> $r = funcA ( funcB ( funcC ($p) ), funcD ($q) );

I wasn't going to comment, but seriously, Rene, I would not make it a
habit of calling functions within the parameters of other functions.
Among other things, it obviously creates a whole host of the problems
you're talking about, and it makes your code hard to debug and read. The
only way I'd normally do something like this is if I were using native
PHP functions and the possible failure of the functions wouldn't matter.
Rather, I'd do something like this:

$d = funcD($q);
// tests if necessary
$c = funcC($p);
// tests if necessary
$b = funcB($c);
// tests if necessary
$r = funcA($b, $d);


Paul M. Foster

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to