logo       

cvs: ZendEngine2(PHP_5_3) / zend_language_parser.y /tests 021.phpt: msg#00073

Subject: cvs: ZendEngine2(PHP_5_3) / zend_language_parser.y /tests 021.phpt
johannes                Wed Nov 21 00:03:16 2007 UTC

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests  021.phpt 

  Modified files:              
    /ZendEngine2        zend_language_parser.y 
  Log:
  - MFH ?: operator (Marcus)
    [DOC] "expr1 ?: expr1" is a shortcut for: "expr1 ? expr1 : expr2" as
          exists in gcc and discussed some time back. Note that this is not
          an implementation ifsetor($var, default). While ifsetor would not
          generate any message for non existing variables or array indices
          the ternary shortcut does. Also the ternary shortcut does a boolean
          evaluation rather then checking for isset(). That way ther ternary
          shortcut can work on any expression while ifsetor can only work on
          variables. Also to be silent one has do do: "@$expr1 ?: $expr2".
    
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_language_parser.y?r1=1.160.2.4.2.8.2.8&r2=1.160.2.4.2.8.2.9&diff_format=u
Index: ZendEngine2/zend_language_parser.y
diff -u ZendEngine2/zend_language_parser.y:1.160.2.4.2.8.2.8 
ZendEngine2/zend_language_parser.y:1.160.2.4.2.8.2.9
--- ZendEngine2/zend_language_parser.y:1.160.2.4.2.8.2.8        Tue Nov 20 
08:53:02 2007
+++ ZendEngine2/zend_language_parser.y  Wed Nov 21 00:03:16 2007
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_parser.y,v 1.160.2.4.2.8.2.8 2007/11/20 08:53:02 dmitry 
Exp $ */
+/* $Id: zend_language_parser.y,v 1.160.2.4.2.8.2.9 2007/11/21 00:03:16 
johannes Exp $ */
 
 /*
  * LALR shift/reduce conflicts and how they are resolved:
@@ -611,6 +611,9 @@
        |       expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
                expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); }
                expr     { zend_do_qm_false(&$$, &$7, &$2, &$5 TSRMLS_CC); }
+       |       expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
+               ':'      { zend_do_qm_true(&$1, &$2, &$4 TSRMLS_CC); }
+               expr     { zend_do_qm_false(&$$, &$6, &$2, &$4 TSRMLS_CC); }
        |       internal_functions_in_yacc { $$ = $1; }
        |       T_INT_CAST expr         { zend_do_cast(&$$, &$2, IS_LONG 
TSRMLS_CC); }
        |       T_DOUBLE_CAST expr      { zend_do_cast(&$$, &$2, IS_DOUBLE 
TSRMLS_CC); }

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/021.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/021.phpt
+++ ZendEngine2/tests/021.phpt
--TEST--
?: operator
--FILE--
<?php
var_dump(true ?: false);
var_dump(false ?: true);
var_dump(23 ?: 42);
var_dump(0 ?: "bar");

$a = 23;
$b = 0;
$c = "";
$d = 23.5;

var_dump($a ?: $b);
var_dump($c ?: $d);

var_dump(1 ?: print(2));
?>
--EXPECT--
bool(true)
bool(true)
int(23)
string(3) "bar"
int(23)
float(23.5)
int(1)
--UEXPECT--
bool(true)
bool(true)
int(23)
unicode(3) "bar"
int(23)
float(23.5)
int(1)

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe