Michael Dowling has a new post to his site announcing a project he's recent released to try to bring some of the functionality of Clojure to PHP with the introduction of transducers.
Rich Hickey recently announced that transducers are going to be added to Clojure, and it prompted quite a bit of discussion. After a somewhat brief announcement, Hickey followed up with a couple videos that describe transducers in much more detail: Transducers and Inside Transducers + more.async. Transducers are a very powerful concept that can be utilized in almost any language. In fact, they have been ported to various other languages including JavaScript (1 and 2), Python, Ruby, Java, and Go. And now…transducers are available in PHP via transducers.php!
He starts with an official definition of what a transducer is from the Clojure documentation then explains it in a bit more layman's terms as "a fancy way of saying that you can use functions like map and filter on basically any type of data source (not just sequences)" and can output any kind of structure as a result. He then gets into some code examples using his project showing eager and lazy evaluation, how they're composable and a list of the ones the library makes available (and what they do). He then gets into a more complete example of their application with a streams example, working with/modifying a string. He ends the post looking at how to create your own custom transducer and how they compare to generators.
Link: http://mtdowling.com/blog/2014/12/04/transducers-php/
没有评论:
发表评论