Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77820 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15261 invoked from network); 7 Oct 2014 20:07:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Oct 2014 20:07:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.51 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.218.51 mail-oi0-f51.google.com Received: from [209.85.218.51] ([209.85.218.51:51483] helo=mail-oi0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/11-30869-EE744345 for ; Tue, 07 Oct 2014 16:07:10 -0400 Received: by mail-oi0-f51.google.com with SMTP id h136so2939141oig.24 for ; Tue, 07 Oct 2014 13:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=ZCb4QXWfCv1iTQQDBoynXzxIEFFaRzF76ad9DwqHjyI=; b=Cn0v6WEG8TxuB55iRl9pCBkTAMVKgESpin4T/eiQ8EhEZlP8O6MnzTOSKguyNl2oAc FXsxuxy46mD+0MESVuOrJli/G/gtMAyyhODAYHxS0f8SIcvK4qQ1LnveGo47Ssub1eph 7x7VwNVBYN5OXdetHKyRxg+kp4a/uo2OPU8GvcPSC/aoghNvwodVSS9V9hN/T6OFhz+Y JUohM4jN7P4dAK5brz5zVb8GpqbwcA0WbIgTzvxeyqzraFhPr+EaZ+4vTIP80ZxQRL2P 42ajGTGqv2qXyEqCmq4jipklEgIQKxRrwFqaIPYiLdnv4LSzfIZgYEe/FsQrmlZq4nHL VKmg== MIME-Version: 1.0 X-Received: by 10.182.119.230 with SMTP id kx6mr7146922obb.72.1412712428100; Tue, 07 Oct 2014 13:07:08 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.76.75.37 with HTTP; Tue, 7 Oct 2014 13:07:08 -0700 (PDT) In-Reply-To: References: <9CFCFC24-A670-4DBC-8042-C073B62958A2@strojny.net> <5433F174.8060204@gmail.com> Date: Tue, 7 Oct 2014 14:07:08 -0600 X-Google-Sender-Auth: grxOJpBNUhAuHO8Iy3_0aYfVKjk Message-ID: To: Rowan Collins Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Exceptions in the engine From: levim@php.net (Levi Morrison) >> I would also argue that >>you should never, in any language, catch a NPE. The only time you >>should catch an NPE is if you are catching all exceptions, such as in >>a FastCGI daemon that will cleanly shutdown afterwards. > > If you're not allowed to catch it, why make it an exception? Benefits such as unwinding finally blocks and destructors, and collecting backtraces, are secondary effects, not really fundamental to exceptions. This is not a new idea; a very quick search turned up the CERT Oracle Coding Standard for Java: "Programs must not catch java.lang.NullPointerException. A NullPointerException exception thrown at runtime indicates the existence of an underlying null pointer dereference that must be fixed in the application code[...] Handling the underlying null pointer dereference by catching the NullPointerException rather than fixing the underlying problem is inappropriate for several reasons." I'll let you read the standard for the justification. The point is that a few applications (and I mean a *very* few) need to be able to handle these kinds of failures; for example a web server shouldn't crash because the application throws a NullPointerException; rather the worker dies and the client will be sent a 500 error and the web server continues to run normally.