 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Eli White's Blog: An intriguing use of lambda functions
by Chris Cornutt March 11, 2010 @ 08:48:16
In a new post to his blog today Eli White takes a look at an interesting use of lambda functions he's figured out for a his development at work.
I found a very specific use out of the blue of Lambda functions that I have now used and I see as a great use-case. Which is specifically passing functions/logic from your Controller to your View. In the case of Goodsie, I'm using PHP for my templating language and as usual I'm trying to remove as much logic from my View as possible, while still allowing the view to be malleable.
His method centered around a pagination subview that he wanted to make flexible enough to work with both the standard page view and with an ajax request. Lambda functions came to the rescue by dynamically creating a function based on the request need.
voice your opinion now!
lambda function pagination subview tutorial
Dagfinn Reiersol's Blog: Real programming with PHP 5.3 (part 4) A more realistic example
by Chris Cornutt June 05, 2009 @ 07:57:21
On the PHP in Action blog Dagfinn Reiersol continues his look at real programming examples using the upcoming PHP 5.3 release. In this new tutorial he focuses on making a classed based on the Range design pattern to paginate results.
A Range object is defined by just two values (three in my variation), so it might seem like too much to have an object just to keep these values, but as you can see from the example, a Range class can have behaviors to change and compare ranges.
He gives two code snippets - the first defines most of the methods of the class in the constructor (using the lambda functions) and the second uses a __call to catch the calls to the same methods but defined normally as private (making them inaccessible to the outside world).
voice your opinion now!
lambda designpattern range tutorial
PHPClasses.org: Upcoming PHP 5.3 features and beyond
by Chris Cornutt April 28, 2009 @ 07:56:34
This new post to the PHPClasses.org blog take a look at some of the new features that will be included in the PHP 5.3 release (coming soon to a web server near you!) by way of an interview with Lukas Smith.
his article presents an interview with core PHP developer Lukas Kahwe Smith that has pushed many of the new features of PHP 5.3 as release manager. Lukas talks about PHP 5.3 new features such as lambda functions, closures and PHAR support. He also explains what are traits, which for now it is a feature that was left out of PHP 5.3. He also talks about future PHP 5.x and PHP 6, as well how anybody can help in the development of PHP to make it come out faster.
They talk about the PHP.net wiki, briefly touch on the PHP 5.3 feature updates, performance/memory usage in the new version, Lambda functions, closures and PHAR and what's to come with PHP 6.
voice your opinion now!
lukassmith php5 upcoming php6 interview phar closures lambda memory usage
Fabien Potencier's Blog: On PHP 5.3, Lambda Functions, and Closures
by Chris Cornutt April 17, 2009 @ 10:29:43
In this new post to his blog Fabien Potencier looks at two of the much-hyped features of the upcoming PHP 5.x series release (5.3) - closures and lambda functions.
I won't talk too much about what lambda functions or closures are, as you can find many good blog posts describing them in great details. To sum up, a lambda function is an anonymous PHP function that can be stored in a variable and passed as an argument to other functions or methods. A closure is a lambda function that is aware of its surrounding context.
He includes several examples including how they would work with a few of the array functions, an implementation of the Y-combinator method (as written by Stanislav Malyshev) and how they can be used to create dependency injection functionality.
voice your opinion now!
lambda function closure php5 array ycombinator dependency injection container
Jeff Moore's Blog: Closures (& Lambda Functions) are coming to PHP
by Chris Cornutt March 23, 2009 @ 11:14:18
Jeff Moore has a new post showing an example of a feature that will be included in the upcoming PHP 5.3 release - closures/lambda functions.
Dagfinn has a post looking at using the new closure feature of PHP 5.3. He compares using foreach for iteration versus array_map. "Interesting," he concludes, "but not necessarily better than conventional alternatives." I agree for that case. Consider instead, a more complicated operation that requires a setup and a tear down after.
Jeff's example proposes that, instead of duplicating code, you use a lambda function to handle the custom parsing of the data as needed and pass that into the "doIt" function in his example.
voice your opinion now!
closure lambda example php5 setup teardown
|
Community Events
Don't see your event here? Let us know!
|