Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51889 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15394 invoked from network); 14 Apr 2011 10:40:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2011 10:40:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:32883] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9A/EB-44901-B1FC6AD4 for ; Thu, 14 Apr 2011 06:40:28 -0400 Received: by bwz18 with SMTP id 18so1390790bwz.29 for ; Thu, 14 Apr 2011 03:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=Kxp1+EmQJwLHbbK7STth6vcE7cjhAAXwJtyn+noUSrg=; b=CSw0pKbi7EQ0QsI0dXQ/jxTa0opsLmcXzXct16pNDIHafuC43JiRiKq0iiARanJSRf 5aBB05k4/nxgObekfIaGy4itIn3RhbTSTDI+NvS1vb0T7zGeCTOwgx9cpmJZDYkYyl2X QTcM5U4ILDhI3g461trfGEcy3st8ViveyV/HA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=OTY3PFKFOawFWArXbSW+XGOMZeb1FsE0xXNi4mmsoORr+IxKg7JbdgyBiB4+85P53Y C4efzdW1Syr9UVe7qLvsDTB5uiRBP9J6LY9AcFn5NsA9xm4u3OVVTuujHCIxxY8/WPQd 3Y1mcO5P+fMi8/thZtnvOFIl2EIGWJVnKzGl0= MIME-Version: 1.0 Received: by 10.204.136.1 with SMTP id p1mr446956bkt.105.1302777624571; Thu, 14 Apr 2011 03:40:24 -0700 (PDT) Sender: tyra3l@gmail.com Received: by 10.205.83.198 with HTTP; Thu, 14 Apr 2011 03:40:24 -0700 (PDT) In-Reply-To: <4DA65BEC.8000809@gmail.com> References: <4D950434.3060704@yahoo.com.au> <4D9E0543.1080600@lerdorf.com> <69.82.36433.EC33E9D4@pb1.pair.com> <4D9E34C4.5000406@lerdorf.com> <4D9E429B.20503@sugarcrm.com> <4D9E96B6.6060401@lerdorf.com> <718216446.20110408143441@cypressintegrated.com> <4DA0E71C.9030008@gmail.com> <4DA63ED8.4080402@yahoo.com.au> <4DA65BEC.8000809@gmail.com> Date: Thu, 14 Apr 2011 12:40:24 +0200 X-Google-Sender-Auth: Zg6hbTJv_0vrbRR5_05PIi3pJmQ Message-ID: To: David Muir Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0015174c1c5c88b1ea04a0de8d5a Subject: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: info@tyrael.hu (Ferenc Kovacs) --0015174c1c5c88b1ea04a0de8d5a Content-Type: text/plain; charset=UTF-8 inline posted > I cry whenever I see code with @ in it... > > I always cry when somebody thinks that the @ cannot be used correctly. btw we have the scream extension and xdebug.scream also, and you could use an error handler to "scream" the errors suppressed by @, so I don't know why are you crying. > > What we're wanting are existential assignment and ternary operators. > Simply put, a painless way to set or use a default value based on the > existence of a variable without needing a bunch of extra code to avoid > notices/errors. Sorry Ben, but I think extending the @ operator to > prevent errors from being generated in the first place is a terrible > idea. I would prefer to see @ removed from PHP if possible. > > > there are cases where you can't write clean code without @. for example there is an instruction, which can generate an error and you can predict that it is "safe" to execute or not. for example: - http://php.net/manual/en/simplexmlelement.construct.php - http://php.net/manual/en/function.simplexml-load-file.php which can be worked around with http://php.net/manual/en/function.libxml-use-internal-errors.php or another example would be serialize/unserialize: http://www.php.net/manual/en/function.unserialize.php it can be a perfectly valid to suppress the notice and check for the return value of the serialize/unserialize call to handle errors locally. another example: you have a script, which checks for a cache file, if present then you simply read it, if not, then you generate the result and write it to the cache file, which gets invalidated(deleted) if it's older than x. but you can't atomically check the existence of the file then read it. and it can happen (race condition) that you the file was present when you checked with file_exists, but it is deleted when you try to open it in the next line. I think that it could be a good idea to provide an operator to not just change the error reporting level, but to simply prevent the error generation. of course its a tricky question: should we discard the error if an error handler is registered? Tyrael --0015174c1c5c88b1ea04a0de8d5a--