On Tue, 2007-12-11 at 22:33 -0600, Gregory Beaver wrote:
> Any brackets adds another set of shift/reduce to the parser, regardless
> of how the syntax of the language is defined.

That's not all with that syntax.

<?php
{
    class foo { }
}
?>

Leads to a delayed declaration which is done at run-time, not at
compile-time - this might have bigger performance issues than just the
shift/reduce in the parser - especially with opcode caches.

 $ php53 -dvld.active=1 -dvld.execute=0 -r '{ class foo { }}'
Branch analysis from position: 0
Return found
filename:       Command line code
function name:  (null)
number of ops:  5
compiled vars:  none
line     #  op                           fetch          ext  return
operands
-------------------------------------------------------------------------------
   1     0  NOP                                                      
         1  EXT_STMT                                                 
         2  ZEND_DECLARE_CLASS                               null
'%00fooCommand+line+code0x998387c', 'foo'
         3  RETURN
null
         4* ZEND_HANDLE_EXCEPTION                                    

Class foo: [no user functions]

vs.

$ php53 -dvld.active=1 -dvld.execute=0 -r 'class foo { }'Branch analysis
from position: 0
Return found
filename:       Command line code
function name:  (null)
number of ops:  4
compiled vars:  none
line     #  op                           fetch          ext  return
operands
-------------------------------------------------------------------------------
   1     0  EXT_STMT                                                 
         1  NOP                                                      
         2  RETURN
null
         3* ZEND_HANDLE_EXCEPTION                                    


johannes

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

Reply via email to