On Wed, January 3, 2007 8:24 am, Roman Neuhauser wrote: > I don't follow the logic. What did we gain? Can one of those > "exceptions > == Java, Java stinks, exceptions stink" campers show me their version > of > the below f($any) that works in 5.1 and 5.2? Sure. > > function f($any) > > { > > printf("%s\n", $any); > > } function print_any($any){ switch(gettype($any)){ case "boolean": // (since PHP 4) echo $any ? "true\n" : "false\n"; break; case "integer": case "double": //aka float case "string": echo "$any\n"; break; case "array": var_dump($any); echo "\n"; break; case "object": //you could check for the method __toString() if you like. var_dump($any); echo "\n"; break; case "resource": //(since PHP 4) echo "Internal PHP Resource: $any\n"; break; case "NULL": //(since PHP 4) echo "NULL\n": break; case "user function": // (PHP 3 only, deprecated) echo "UPGRADE! Function: $any\n"; break; case "unknown type": default: echo "unknown data type\n"; error_log(__FILE__ . ": " . __LINE__ . " unknown data type. Check gettype documentation"); break; } } The problem with try/catch is that, as already noted in this thread, as soon as you reach a certain level of complexity and a large enough code-base, the whole house of cards comes tumbling down because one developer somewhere isn't using the same semantics for errors as you are. This can be as obvious as not using try/catch at all, to something very subtle such as what to *DO* with the errors or what kinds of errors to catch. So, actually, it's not about try/catch being Java, as try/catch did not originate with Java, as it is about try/catch just not being scalable to wide-spread development. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php