2 ms·
I don't think you can call these antipatterns. It's just a classic example of writing one language in another language. Ironically though, the author happens to
by yason 17y ago
I don't think you can call these antipatterns. It's just a classic example of writing one language in another language. Ironically though, the author happens to use a closure in the examples 3C and 3D. Har har.
While closures and objects have something in common (both can, for example, store state) they're of quite different mindsets. And you can't easily mix mindsets because such mindsets are the terms in which the programmer thinks in. Try writing a program both in Java-mindset and in Haskell-mindset in the same source file of Java, Haskell, or C.
There's code where using objects instead of closures would look abhorring and there's code where using closures would look totally out of the place. There's also a related koan that was just referred on HN a few days ago.