Re: [PHP-DEV] Of string constants, bytecode, and concatenation

[email protected] (David Brown)
Newsgroups php.dev
Message-ID <[email protected]>
On Wed, Feb 26, 2003 at 05:36:54PM +0100, Derick Rethans wrote:
| No, the engine doesn't do this at compile time. This first one produces:
| 
| number of ops:  5
| line     #  op                   fetch  ext operands
| -------------------------------------------------------------------------------
|    1     0  CONCAT                          ~1, 'foo', 'bar'
|          1  CONCAT                          ~2, ~1, 'baz'
|          2  FETCH_W              local      $0, 's1'
|          3  ASSIGN                          $3, $0, ~2
|    3     4  RETURN                          1
| 
| The second one:
| 
| line     #  op                   fetch  ext operands
| -------------------------------------------------------------------------------
|    1     0  FETCH_W              local      $0, 's2'
|          1  ASSIGN                          $1, $0, 'foobarbaz'
|    2     2  RETURN                          1

Is that output a ZEND_DEBUG thing, or is that an external tool?


| > If not, can anyone explain the barriers to doing something like this?
| 
| It's the job of an optimizer, not of a compiler. And because PHP doesn't 
| have an internal optimizer, this is not optimized out. You can either 

Okay. Makes complete sense. I was thinking more along the lines of
"wouldn't it be nice if...?". I hadn't quite made it to "where would
that belong?". :)

I'll check out the optimizers. I noticed that the new CVS version of APC
seems to have a configuration option for optimization as well, though
I'm not sure how far along it is.


Thanks again,

- Dave
  [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.