Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51861 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84473 invoked from network); 11 Apr 2011 12:20:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Apr 2011 12:20:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=mail_ben_schmidt@yahoo.com.au; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mail_ben_schmidt@yahoo.com.au; sender-id=unknown; domainkeys=good Received-SPF: error (pb1.pair.com: domain yahoo.com.au from 98.139.91.81 cause and error) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: mail_ben_schmidt@yahoo.com.au X-Host-Fingerprint: 98.139.91.81 nm11.bullet.mail.sp2.yahoo.com Received: from [98.139.91.81] ([98.139.91.81:30213] helo=nm11.bullet.mail.sp2.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4B/07-29000-EF1F2AD4 for ; Mon, 11 Apr 2011 08:20:15 -0400 Received: from [98.139.91.66] by nm11.bullet.mail.sp2.yahoo.com with NNFMP; 11 Apr 2011 12:20:11 -0000 Received: from [98.139.91.11] by tm6.bullet.mail.sp2.yahoo.com with NNFMP; 11 Apr 2011 12:20:11 -0000 Received: from [127.0.0.1] by omp1011.mail.sp2.yahoo.com with NNFMP; 11 Apr 2011 12:20:11 -0000 X-Yahoo-Newman-Id: 548332.18748.bm@omp1011.mail.sp2.yahoo.com Received: (qmail 80435 invoked from network); 11 Apr 2011 12:20:11 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=4WvBVRQb41GgDmBsOSsYLFy/+T/3Xf0XMPfmOhheYPIRsLFPCi1Lpf76OT0rHm0h24CSyjFmUdN9A8lGpFAQj33Vrt6ubcYMHyjnXczLN9xBkZlZJu/poZPUhzWxX0um0YnVRjCkos6JR6fAj159NqtTsNhnAoPMeWIN7/Iekh4= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.au; s=s1024; t=1302524411; bh=XXpZ8qJx3b+aoxSs5eZ0RoXn4UZMDgdBD0pWAKO/LvY=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=ZUJ5wj7rIjRsmUnfbrmRnkwCNxf8fKt7zKE7WSUgm/o0vRPYa6NVR45ZXSHs6Nh/A0cE5O8PIfW7w2MzSNMTso3o4nRfiMmNC2NLZ7GotF3PUR3iQBl/0xI5Pp38ECsUtxyyBs5olQNZS6Vd4TDi6kn/bZ2Vu4/H5kHjSDuNIKY= Received: from thought.local (mail_ben_schmidt@124.168.220.198 with plain) by smtp139.mail.mud.yahoo.com with SMTP; 11 Apr 2011 05:20:10 -0700 PDT X-Yahoo-SMTP: enFMnPSswBAexaHyzgobwuUTrYOhZdJ0KRA2SjA- X-YMail-OSG: ngEm4XwVM1mTWE3VN41zngF_qquwSWtivCLdrztaaU_EMsa Yylw8xYPfXen7TiYIMS7dmEpb0H.0mf9wa0CoxA.lGQP8wmV.sV6UCRD7Q99 gy2Os28cuciApmXOTRkH8Fm9W2JvChkZNpdANKpAcJqa_97D3Jftl59baSvZ 8QkrHYxPrrKB_WYNuUDGMCznVHjGLLbzRYzcdjLwKtXOMOEken2EAhVaw5o3 D6HUrRzAwdjZTeW3vlcMMpEIBUi9HsXd09ijK3aB1Lxe4kTYNV.gGwvFTxY. 6kS4cV7.WbmdWBRJXFokfwZ3h3HgjgRrIEUj3l71TORKlWrWaygGT7Nk.eNV H1GNoupE5g2NxKtJ0SdmZ X-Yahoo-Newman-Property: ymail-3 Message-ID: <4DA2F1FC.1020805@yahoo.com.au> Date: Mon, 11 Apr 2011 22:20:12 +1000 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5 MIME-Version: 1.0 To: Hannes Landeholm CC: Stas Malyshev , internals@lists.php.net References: <4DA26602.6080303@lorenso.com> <34592245-F3F3-44B6-9139-4F217CA9C962@gmail.com> <4DA26BB1.3050003@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: mail_ben_schmidt@yahoo.com.au (Ben Schmidt) I think another problem with using @ is that it is done by the caller, not the callee, so it doesn't allow functions like issetor() to be implemented in userland without expecting every caller to do pass the variable while silencing errors. I also don't think the inconvenience is restricted to arrays. I frequently use the idiom isset(X)?X:Y with X simply being a variable. It's not just about silencing a notice, but about providing an alternative/default value. If doing the suppression of undefined notices be better if the ? was put after the opening square bracket, thereby removing the ambiguity (which I think would be more troublesome than you think)? $array[?"foo"] Ben. On 11/04/11 6:10 PM, Hannes Landeholm wrote: > @ 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 >> >> >