Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73643 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38299 invoked from network); 8 Apr 2014 23:10:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2014 23:10:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=marco@m-s-d.eu; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=marco@m-s-d.eu; sender-id=unknown Received-SPF: error (pb1.pair.com: domain m-s-d.eu from 209.85.223.182 cause and error) X-PHP-List-Original-Sender: marco@m-s-d.eu X-Host-Fingerprint: 209.85.223.182 mail-ie0-f182.google.com Received: from [209.85.223.182] ([209.85.223.182:45202] helo=mail-ie0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/80-33769-5E184435 for ; Tue, 08 Apr 2014 19:10:30 -0400 Received: by mail-ie0-f182.google.com with SMTP id y20so1696726ier.13 for ; Tue, 08 Apr 2014 16:10:27 -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:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=S9yz705BYCWCEyfVMYJ3xqjgbwBeHjIudaKlEM9GRXw=; b=WZgJtyGOhoKAsXo+6EmbzgNZo3RcUs/jFudXUDT/lhyUYV8IKgOW4OGl74c8VTU2S8 ApOm05lwxaQdGaGLm16uzMBeFkRE6e1+sHPoMEt6SKTmqj2u13UaiWk+YUmpFgj4VPwP rFSQDmIs7UTVusbnurFhmQi8yWgFekOSg2HXmWwXo2q6+OinFltGHMuU8MuJ8ITYk/30 Q0Cx3PR0qHUE2JhinAiaamnwyXFA0sc4QZBG+uGKv0/YyMKL6VMtwoGIXyBoq/E5UyQW WDbBLvj8DnEQE6H70TKQ3rr2W1EXCdeTAMrBFoRRBXF51Oz32F+ISyUAUxgTqIRm6pNR ipKg== X-Gm-Message-State: ALoCoQm7/nqaMXRwlMn3oRzeuvkDGTyIIbEeUeY5PGMvc+avnZkGjW1L4CtRXVC7uS89VmeQYP8z MIME-Version: 1.0 X-Received: by 10.50.111.138 with SMTP id ii10mr7213752igb.34.1396998626962; Tue, 08 Apr 2014 16:10:26 -0700 (PDT) Sender: marco@m-s-d.eu Received: by 10.64.225.169 with HTTP; Tue, 8 Apr 2014 16:10:26 -0700 (PDT) X-Originating-IP: [46.128.155.165] In-Reply-To: <53446FC5.7000001@gmail.com> References: <53446FC5.7000001@gmail.com> Date: Wed, 9 Apr 2014 01:10:26 +0200 X-Google-Sender-Auth: 7WfKRziVI0TqmKAsnuPfwZMCPmI Message-ID: To: Rowan Collins Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [PHP.next] Error-handling using "Error Events" From: marco+php@m-s-d.eu (Marco Schuster) Hi, On Tue, Apr 8, 2014 at 11:53 PM, Rowan Collins wrote: > The infamous "shut up" operator (@) > ----------------------------------- > > No discussion of error-handling would be complete without mentioning this > little oddity, although I admit to a slight ignorance of exactly how it > works, and why it causes the compiler to skip optimisations. (e.g. > https://gist.github.com/nikic/6699370) > > One thought I had was that you could have a special syntax that could > register a high-priority "discard" pseudo-listener for a few lines of > lexical scope (hopefully that makes sense if you've read this far); > something like this: > > suppress_messages { > $fh = fopen('foo'); > } > > That wouldn't be quite the same as the current @ operator - if you replaced > fopen() with a user-defined wrapper, you'd need dynamic scope again - but it > would replace some use cases. I'm not sure if it would actually make sense > or not, but it gives you an idea of where my mind is going with the whole > "listener"/"pseudo-listener" concept. The fopen shut-up actually could be resolved much, much more elegant: make it throw *real, usable exceptions*, instead of returning a FALSE and spitting out a warning. Something like DomainNotFoundException, ConnectionDeniedException, FileNotFoundException or whatnot. It's a nightmare if you actually want to know what happened. Of course one could also just use the cURL library for http/ftp requests, but it doesn't have exceptions either... and it's a massive boilerplate together with checking every freaking curl_set_option for a FALSE return value. Marco