A Closure-based State implementation in Swift.
Let’s talk a bit about the various pattern implementations, the languages in which they are being written, and what to “get” out of them.
A Closure-based State implementation in F#.
A Closure-based State implementation in Java.
A Closure-based State implementation in C#.
tl;dr Patterns, 20 Years Later: With the prevalance of libraries and tools that can peer past access controls (such as Reflection on the JVM and CLR, or the Mirrors facility in Swift), trying to encapsulate private details away from prying eyes can be increasingly difficult. Other languages lack access controls entirely, or the concept of objects. In any of these languages that offer closures, we can hold state within a closure yet outside of the object, rendering it almost entirely inaccessible to outside parties.