News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Web Species Blog:
Lazy evaluation with PHP
June 01, 2011 @ 08:41:01

Juozas Kaziukenas has a new post to his Web Species blog about using "lazy evaluation" in PHP - loading the resources you need for execution and evaluation only as you need them, not all up front.

Recently I needed to process a huge array of data and because of PHP's somewhat inefficient variables and especially arrays that was resulting in "out of memory" errors. However, I couldn't use any other tools than PHP so was forced to come up with a solution implementation in it. Here is how I solved it using principles from functional languages.

He gives an example using Haskell to generate a Fibonacci sequence using its built-in lazy evaluation abilities. Unfortunately, PHP doesn't have such a thing built in, so he tries the next best thing - Iterators. He caries the idea over to the database side too, recommending fetch() in a loop over fetchAll() and some effective joins.

0 comments voice your opinion now!
lazy evaluation haskell functional iterator


blog comments powered by Disqus

Similar Posts

Web & PHP Magazine: Issue #7 Published - "Full Throttle"

Stubbles Blog: Lazy loading of classes stored in a session without __autoload()

Zend Developer Zone: The Standard PHP Library (SPL)

Alex Netkachov's Blog: 6 PHP coding tips to write less code

Jani Hartikainen: Parsing and evaluating PHP in Haskell: Part 1


Community Events





Don't see your event here?
Let us know!


introduction tool library framework composer laravel release package version podcast application voicesoftheelephpant series symfony interview install language community security opinion

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework