Re: PHP tail call optimization

From: Date: Sat, 21 Mar 2015 16:10:15 +0000
Subject: Re: PHP tail call optimization
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-324691@lists.php.net to get a copy of this message
On 03/20/2015 04:54 PM, Marco Perone wrote:
Hello everybody. From what I understand, PHP does not have tail call optimization. I would like to ask if there is a reason for this. Is it because this limitation comes from the C language? Is it a feature that was never proposed? Is it a technical reason or a "human" one, or is it just that there is no real reason and nobody ever really needed this?
Until very recently the way the engine was written made it prohibitively difficult and costly to do. Prior to PHP 5.5, having no opcode cache was the norm so compile time needed to be kept to an absolute minimum. That's not the case anymore. Also, PHP 5 has no AST. PHP 7 does have an AST, which means it should be possible to add compile-time optimizations like tail recursion optimization. That's not planned for PHP 7.0, but I believe people are discussing the potential of it in 7.1 or 7.2. Stay tuned, or if you know C help out. :-) --Larry Garfield

« previous php.general (#324691) next »