Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51860 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59005 invoked from network); 11 Apr 2011 08:14:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Apr 2011 08:14:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=landeholm@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=landeholm@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: landeholm@gmail.com X-Host-Fingerprint: 209.85.210.170 mail-iy0-f170.google.com Received: from [209.85.210.170] ([209.85.210.170:48150] helo=mail-iy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/E3-29000-B48B2AD4 for ; Mon, 11 Apr 2011 04:14:03 -0400 Received: by iyb12 with SMTP id 12so6628432iyb.29 for ; Mon, 11 Apr 2011 01:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=0LBy97Tl6Ct/smkcv/EGyWUMcz+LOdTtTgU4SmfgbmE=; b=YRaLNKWie4vJDymtQX3jW45FhKkPlcHhHDCi//PudLpPL7ZEc/fODIZgMQjzuMC6Jo dmX17018hdpPKktOuua58WMfZ2XATFHges9ucNmz0GR77Tn4RTVKPYoRGgTBs96rdQLs vEzzRueP0K/VngkUd9L3Sf46HQjKViAap0UBk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=DOdG/Ir3B+e69nowBQ324nWS1jYndXZr7t2jO8qBrQB8d4u3706dRDMyJnmq+1RTXD JIDjVseLPZWEKH1lj+0k5luV4rxt0YhWtKkriIxhEn2G5KpzTWggchmRDOcUe2trfpFj VOkwWX6Qg6UWsoIPehjx9rBhctoqNe9/xhEJU= MIME-Version: 1.0 Received: by 10.42.144.135 with SMTP id b7mr7593994icv.100.1302509457503; Mon, 11 Apr 2011 01:10:57 -0700 (PDT) Received: by 10.231.33.139 with HTTP; Mon, 11 Apr 2011 01:10:57 -0700 (PDT) In-Reply-To: <4DA26BB1.3050003@sugarcrm.com> References: <4DA26602.6080303@lorenso.com> <34592245-F3F3-44B6-9139-4F217CA9C962@gmail.com> <4DA26BB1.3050003@sugarcrm.com> Date: Mon, 11 Apr 2011 10:10:57 +0200 Message-ID: To: Stas Malyshev , internals@lists.php.net Content-Type: multipart/alternative; boundary=90e6ba21231987f4a104a0a01d34 Subject: Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: landeholm@gmail.com (Hannes Landeholm) --90e6ba21231987f4a104a0a01d34 Content-Type: text/plain; charset=ISO-8859-1 @ is not convenient since it turns off error reporting for all errors. I don't know how many times I've silenced a notice and got a blank page in my face as a "thank you for accidentally silencing that fatal error too". "Silent" is reserved for the purpose of the silence operator though @ so using that as a keyword for something else would be confusing. It just struck me that the ~real~ problem is that sometimes you want array access that should define undefined indexes as being null (a good placeholder for this purpose). How about (instead of the previously proposed ?? and isnotempty and whatnot) simply changing the "array access syntax" to simply allow an optional "?" operator at the end signaling that the condition where the index isn't defined isn't unexpected? For example: $value = isset($arr["foo"])? $arr["foo"]: null; $value = isset($arr[$foo])? $arr[$foo]: null; would be replaced with: (respectively) $value = $arr["foo"?]; $value = $arr[$foo?]; it would also worked chained: $value = $arr["foo"?]["bar"]["baz"?] (if [foo] doesn't exist value will be null.. if [foo] exists [foo][bar] is expected to exist but [foo][bar][baz] may or may not exist... if not, value will once again be null) This way it would only apply to array access which was a +1 for some. This could also be extended too replace null with something different (by allowing an expression after the "?" like "null" or "foo" . "bar") but I think careful use-case research should be done to determine if it's really needed first... I realize this partially collides with the use of ? so it would be more difficult to implement but it's far from impossible.. it just requires a little ahead-parsing in brackets [] to know if the "?" is a ternary if or if it's a "not exists is not undefined" operator (is the : missing or not?). Otherwise "??" could simply be used instead or a completely different operator... ~Hannes On 11 April 2011 04:47, Stas Malyshev wrote: > Hi! > > @. >> > > Note however it does not exactly "turn off" the warning, only changes it to > not reported. It's still generated and can be picked up by handlers, for > example. > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --90e6ba21231987f4a104a0a01d34--