3 ms·
What you say works well if you already have your data nicely divided into different kinds of objects. However a useful technique with closures is a dictionary
by btilly 13y ago
What you say works well if you already have your data nicely divided into different kinds of objects. However a useful technique with closures is a dictionary of closures allowing you to map things that may be of the same type to different behavior. Wrapping those in objects so that you can use method dispatch can be a lot of useless work.
As a concrete example I point you at http://www.perlmonks.org/?node_id=34786 http://www.perlmonks.org/?node_id=34786 where I demonstrated how to take transform a markup language into HTML through the technique of grabbing a token, then passing to a closure that is associated with that token to consume a bit of the document. Porting that closure-based code to an OO style would be a nightmare.