Rowan,

> This is certainly some people's concern, but Anatol has raised a subtly
> different consistency-related point, which is this:
>
> Since we have no policy for what kinds of Throwable should be emitted in
> what circumstance, throwing anything in this function sets a precedent which
> will have to be incorporated in any future plan.
>
> Assuming nobody is fundamentally against ever adding Throwables to core
> functions, there are a minimum number of questions that need to be agreed
> before adding the first one:
> - when should we inherit from Error and when from Exception?

IMHO, Errors signify programmer error, where Exceptions signify
unknown or runtime errors. Meaning that an Error should always be a
problem with your code, but an Exception could be a systems problem, a
user problem or a problem in your code.

While that's slightly off-topic to this discussion, it frames which
type random_* would throw pretty clearly (Exception).

> - is it ever OK to throw a plain Error or Exception (thus forcing users into
> the otherwise bad practice of catching those base classes)?

For now, I think that's a good practice. It doesn't constrain us from
sub-typing down the road (7.1, etc), but it also lets us build the
support in today.

For example, if we throw Exception, in 7.1 we could make it
php\RandomException in 7.1 without issue (all we need to get right is
the hierarchy parent).

> - if not throwing the base class, how specific should sub-classes be? (i.e.
> a framework for defining the hierarchy, not necessarily the hierarchy
> itself)

I think this is something that should be RFC'd for 7.1. I don't think
that limits us here though.

> If we can get agreement on those points in time for 7.0, fine, but time is
> very tight, and the window for such discussions has theoretically closed...

I think the only real agreement we need is Error vs Exception. If we
can agree on one of those, we can do the rest in 7.1 without worrying
about BC...

Anthony

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

Reply via email to