Hi everyone:

In trying to do something syntatically fancy with trigger_error() today, I
came across what I believe to be an inconsistency in the way return values are
being applied throughout the PHP4 tree. Proof (hopefully) follows. :)

For functions prototyped as returning void, return values seem to be applied
at random. Some functions, such as trigger_error/user_error, srand, ob_start,
and phpinfo, use RETURN_TRUE. The vast majority of these functions just fall
through, implicitly returning NULL to userland.

IMHO, it'd add a bit of syntactic sugar to the language to allow a function
returning void to always return a NULL/unset value. Things like:

  if ($doomed)
    return trigger_error('Error', E_USER_WARNING);

could take the place of longer constructs like:

  if ($doomed)
  {
    trigger_error('Error', E_USER_WARNING);
    return NULL;
  }

With exceptions coming, this may be a really weak point, but I figured I'd
through it out here.

A much stronger argument than the above, however, is just maintaining
consistency throughout the engine and extensions. I'm more than willing to do
the legwork on this one, if you guys are okay with it. Anyone want to dictate
an official policy? :)


Kind regards,

- Dave
  [EMAIL PROTECTED]


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

Reply via email to