Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87412 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40934 invoked from network); 30 Jul 2015 17:12:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jul 2015 17:12:46 -0000 Authentication-Results: pb1.pair.com header.from=scott@paragonie.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=scott@paragonie.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain paragonie.com from 209.85.192.49 cause and error) X-PHP-List-Original-Sender: scott@paragonie.com X-Host-Fingerprint: 209.85.192.49 mail-qg0-f49.google.com Received: from [209.85.192.49] ([209.85.192.49:36331] helo=mail-qg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/C0-34806-D0B5AB55 for ; Thu, 30 Jul 2015 13:12:45 -0400 Received: by qgeh16 with SMTP id h16so28555500qge.3 for ; Thu, 30 Jul 2015 10:12:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=zE8gfgjPGVq3hnlTvD+FZhoXo8/a9aS0z3D7e4xbo90=; b=JtVRz1XKvV9xvLKrhMerk3rKPYIIeMGns0JDG/9JCz5grckLSu5v4i8loUETo1DdIU qhZdA5tjuLtRyRJbkaKewbohZEUcC/qQ0Y/yqWU7xnU21d9gd/dyT8Fjz2jsEbmwfX5T wJyjFmUCshZ98Ny8D11XjzUWf4yf/79twSKby3iz9geOAW9Ze3EZP5PMWgLrZxxiQDF7 81wHEzdHanIPM7sSpO0owg4szpBALlsBqa4L0B318Us4r2xdx5+B/mgjb1/B/SQMKhdG BRLlwMfui9nyuWssxgXZZ/jOJ6HolWa0N+jVxGrAF9RndPhmyHwK1v9UgmQo0VLf/FrR qwrw== X-Gm-Message-State: ALoCoQnM0pVy2x7sbaIIMyxWoeXGfrcmIo9duOfiUykYTC0ivjGF0q2XLl0j9tUlZLLWGTkKLx9y MIME-Version: 1.0 X-Received: by 10.140.85.208 with SMTP id n74mr71103686qgd.67.1438276362860; Thu, 30 Jul 2015 10:12:42 -0700 (PDT) Received: by 10.96.83.102 with HTTP; Thu, 30 Jul 2015 10:12:42 -0700 (PDT) In-Reply-To: References: <836BA21C-AE99-4E7B-AB06-EBC30E41BA0E@icicle.io> <0AD335F5-35F3-4D98-8F82-800A1EDF8FD8@icicle.io> <05f101d0c838$fcdab5e0$f69021a0$@belski.net> <55B63FDF.6050100@gmail.com> <55B66494.1020106@gmail.com> <55B6707A.3040405@gmail.com> Date: Thu, 30 Jul 2015 13:12:42 -0400 Message-ID: To: Anthony Ferrara Cc: Rowan Collins , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Core functions throwing exceptions in PHP7 From: scott@paragonie.com (Scott Arciszewski) On Mon, Jul 27, 2015 at 2:03 PM, Anthony Ferrara wrote: > 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 I'm fine with either Error or Exception. I'd prefer Exception (easier to write a sane backport for PHP 5.6) but I leave this decision in the hands of others. /** * Slightly insane PHP 5 backport but it works */ class Error extends Exception { } // Done! Does anybody feel particularly strong about one or the other? If so, should we set up a vote somewhere? (I don't vote karma on RFCs etc. so I don't know if the existing infrastructure would work.) If not, can we get PR 1397 & 1398 merged? :) Regards, Scott Arciszewski Chief Development Officer Paragon Initiative Enterprises