No tail call optimization in PHP (yet)
Steve Claridge
Posted on October 20th, 2012
In a previous post about functional programming in PHP I used an example of reading a text file to show how a functional style of programming is different from ‘normal’ PHP coding. The example was functional in that it used first-class functions (a function treated like a variable) but there was one bit that still used an imperative style, the while loop at the end: while ( ( $l = $line() ) != null ) { echo $l; }; This while loop is a sequence of statements that change a program state, whereas we want to write some code that describes how the next line will be read from the file. To do this we need to write a recursive function instead of the…
Photo by: _ElijahPorter