by quotemstr · 10y ago · 0 comments
In that case, your lambda object is your strategy. One of the good points that the "Design Patterns" authors make and that everyone else ignores is that these patterns are names for recurring structures that pop up independently of implementation language and environment. Some silly functor object is one way of implementing the more abstract "Strategy" pattern. Your lambda is a better one in many cases. It's the same high-level concept.
Was it Steve Yegge who menationed the Perl community calling Design Patterns "FP for Java"?
https://sites.google.com/site/steveyegge2/singleton-consider...
(define (make-counter n)
(lambda (c)
(set! n (+ n c))
n))
This is a HOF, but not an instance of Strategy.