FAQ
Hi,

I am new to the PHP internals, and I was just looking through the code
related to parsing break/continue statements. It looks that as of PHP
5.4, Zend/zend_language_parser.y accepts both "T_BREAK expr" and
"T_CONTINUE expr" and check to make sure "expr" is a positive integer
in the function zend_do_brk_cont. Doesn't it make more sense to
replace "T_BREAK expr" with "T_BREAK <positive integer>" (the same
goes for the continue statement)?

Thanks in advance!

kiyoto

Search Discussions

  • Johannes Schlüter at Jul 28, 2011 at 11:54 pm

    On Thu, 2011-07-28 at 16:10 -0700, Kiyoto Tamura wrote:
    Hi,

    I am new to the PHP internals, and I was just looking through the code
    related to parsing break/continue statements. It looks that as of PHP
    5.4, Zend/zend_language_parser.y accepts both "T_BREAK expr" and
    "T_CONTINUE expr" and check to make sure "expr" is a positive integer
    in the function zend_do_brk_cont. Doesn't it make more sense to
    replace "T_BREAK expr" with "T_BREAK <positive integer>" (the same
    goes for the continue statement)?
    T_BREAK expr allows things like

    $foo = rand(...);
    break $foo;

    but we've dropped that for performance reasons in 5.4.

    johannes
    Thanks in advance!

    kiyoto
  • Kiyoto Tamura at Jul 29, 2011 at 2:25 am
    Hi Johannes,

    Thanks for your reply :) What I meant was that why does the parser
    still accept any expression after T_BREAK/CONTINUE and defer the error
    check to zend_do_brk_cont? Isn't it clearer to only accept if the
    expression following T_BREAK/CONTINUE is a positive integer (if there
    is any expression at all)?

    Kiyoto

    2011/7/28 Johannes Schlüter <johannes@schlueters.de>:
    On Thu, 2011-07-28 at 16:10 -0700, Kiyoto Tamura wrote:
    Hi,

    I am new to the PHP internals, and I was just looking through the code
    related to parsing break/continue statements. It looks that as of PHP
    5.4, Zend/zend_language_parser.y accepts both "T_BREAK expr" and
    "T_CONTINUE expr" and check to make sure "expr" is a positive integer
    in the function zend_do_brk_cont. Doesn't it make more sense to
    replace "T_BREAK expr" with  "T_BREAK <positive integer>" (the same
    goes for the continue statement)?
    T_BREAK expr  allows things like

    $foo = rand(...);
    break $foo;

    but we've dropped that for performance reasons in 5.4.

    johannes
    Thanks in advance!

    kiyoto
  • Jan Dolecek at Aug 3, 2011 at 12:26 pm
    I guess to get a clear error message, because this is a BC change.
    Many people would wonder why working scripts are causing parse errors
    after upgrade of php. Makes sense to have error messages as clear as
    possible ;)

    Jan Dolecek
    juzna.cz@gmail.com



    2011/7/29 Kiyoto Tamura <owenestea@gmail.com>:
    Hi Johannes,

    Thanks for your reply :) What I meant was that why does the parser
    still accept any expression after T_BREAK/CONTINUE and defer the error
    check to zend_do_brk_cont? Isn't it clearer to only accept if the
    expression following T_BREAK/CONTINUE is a positive integer (if there
    is any expression at all)?

    Kiyoto

    2011/7/28 Johannes Schlüter <johannes@schlueters.de>:
    On Thu, 2011-07-28 at 16:10 -0700, Kiyoto Tamura wrote:
    Hi,

    I am new to the PHP internals, and I was just looking through the code
    related to parsing break/continue statements. It looks that as of PHP
    5.4, Zend/zend_language_parser.y accepts both "T_BREAK expr" and
    "T_CONTINUE expr" and check to make sure "expr" is a positive integer
    in the function zend_do_brk_cont. Doesn't it make more sense to
    replace "T_BREAK expr" with  "T_BREAK <positive integer>" (the same
    goes for the continue statement)?
    T_BREAK expr  allows things like

    $foo = rand(...);
    break $foo;

    but we've dropped that for performance reasons in 5.4.

    johannes
    Thanks in advance!

    kiyoto
    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJul 28, '11 at 11:10p
activeAug 3, '11 at 12:26p
posts4
users3
websitephp.net

People

Translate

site design / logo © 2022 Grokbase