3 ms·
>I loved the Smalltalk block closure, the fact that it was a reified object type that you could extend and use polymorphically Some example of that?
by coldtea 7y ago
>I loved the Smalltalk block closure, the fact that it was a reified object type that you could extend and use polymorphically
Some example of that?
- CodeArtisan 7y agoMemoization. You could add a method to the class implementing blocks. Block>>memoize "Return a memoized one-argument block" | cache | cache := Map new. ^[:arg | cache at: arg ifAbsentPut: [self value: arg]] aBlock := [:foo | foo + 1]. aBlockMemoized := aBlock memoize.