Jason Garber wrote:
   public static function forName($name, $c = NULL) {
      if(is_null($c))
         //...
      elseif($c instanceof ClassLoader)
         //...
      else
         //Throw an error

Error handling can be boring/tricky/cluttering and that's why most people will simply omit it or die() here. It's basically dead code which is A Bad Thing IMHO.


I think

function forName($name, ClassLoader $classloader = NULL)
{
        if (!$classloader)
                $classloader = new ClassLoader;

        ...
}

would be much nicer, doesn't have error handling bloat and is as safe.

All we'd need is to ignore the type hint for the default value. Simple, easy to understand and also safe as the two are close to each other (the same line) so no danger of discrepancy here. IMHO :-)

But I got to the conclusion that as long as we don't introduce a new keyword/syntax for allowing/disallowing null I'm happy :-)

Over and out,
- Chris

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



Reply via email to