Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51775 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21448 invoked from network); 31 Mar 2011 16:29:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2011 16:29:53 -0000 Authentication-Results: pb1.pair.com header.from=david.coallier@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=david.coallier@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: david.coallier@gmail.com X-Host-Fingerprint: 74.125.83.170 mail-pv0-f170.google.com Received: from [74.125.83.170] ([74.125.83.170:50412] helo=mail-pv0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/99-04048-00CA49D4 for ; Thu, 31 Mar 2011 11:29:52 -0500 Received: by pvg16 with SMTP id 16so518906pvg.29 for ; Thu, 31 Mar 2011 09:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:date:x-google-sender-auth :message-id:subject:from:to:content-type; bh=+yNN3H8YHPWZrkm5YRmP2es8yHkRlGJxc3XQ7ZQZ994=; b=nIuQ2W/sMGlyhjYuoCu5yBFMClRnpHHv7bAwGy4K9PDkP6MQ4U1fgHVgxaUcwJvgjE lhmUxIRvk2qwCCswiVlyhCmH6Gra6s/hq7FqO1tng74F1uDqXh9NopZC1SaKkZNeRI65 O1bwmSJ6/B1XOSOw070B/reZuYwZ6+hIEnndI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=xCWbnUstXHm9WE+YrrzKs4ItJDkL5RMAFdxXAfFzwJmf0BwVyPJj1cDxNbzvLAYIe3 kSmrEStmsHZwrWBmWodDX5MKG7WmXWx5UDa7iEP0vwL9Rwy6eLqcrZ55UmxYqlR8wYnQ 5EAOA4l7XH7NwWElnBgjUxOSxwb47qhIu20PI= MIME-Version: 1.0 Received: by 10.236.200.137 with SMTP id z9mr1692670yhn.100.1301588989043; Thu, 31 Mar 2011 09:29:49 -0700 (PDT) Sender: david.coallier@gmail.com Received: by 10.147.137.18 with HTTP; Thu, 31 Mar 2011 09:29:49 -0700 (PDT) Date: Thu, 31 Mar 2011 17:29:49 +0100 X-Google-Sender-Auth: usCcXtwh0QWMKTKBmVUCbNDg_HU Message-ID: To: internals Content-Type: text/plain; charset=UTF-8 Subject: Implicit isset/isempty check on short-ternary operator From: davidc@php.net (David Coallier) Hey there, I've been working on a little patch that will allow variables ($1) in a short-ternary operation to go through an implicit isset (zend_do_isset_or_isempty) check so that the average use-case for the short-ternary operator doesn't yield in a notice whenever the first variable of the expression isn't set. So the use-case I'm considering is the following: 'list'); echo $list['name'] ?: 'List not set.' . PHP_EOL; echo $list['name-notset'] ?: 'List not set.' . PHP_EOL; ?> This example, which we all know, will result in a notice for the second echo statement because the requested array-key doesn't actually exist in the array. Now, looking at the original implementation thread of ifsetor and ?: I can see that Marcus' patch had an implicit isset() on the first variable but I cannot seem to track down why this wasn't implemented in the final patch. I'm merely looking for counter-arguments as to why an implicit isset/isempty should not be performed when the first argument is indeed a variable and not an expr. The only counter-argument (If this can even be considered remotely related to an argument) is that having an implicit isset() would return the boolean value of the check. See in the common misconceptions of ifsetor on the wiki [1] I am not trying to revive ifsetor() because I believe this is an amazingly ugly language construct and I don't think it has an actual place in PHP however, implicitly performing the ifestor check on "variable"s and not "expr" could greatly improve it's usability I believe. Anyone has notes about the arguments against the implicit check at the Chicago Round-Table meeting? Thanks, [1] Ifsetor cached wiki rfc: http://webcache.googleusercontent.com/search?q=cache:jKrV2u7jeokJ:wiki.php.net/rfc/ifsetor+php+ifsetor+patch&cd=1&hl=en&ct=clnk&gl=us&client=firefox-a&source=www.google.com -- David Coallier