Write a decorator like class that will:
(1) Pass any message through to its decorated object.
(2) Record the sequence of messages that passed through it.
(3) Playback the messages to a different object.[1]
The theory is that this should be almost trivial in MOO languages and difficult in FOO languages.
Example Usage:
\n s = "Hello, World"\n pb = PlayBack.new(s)\n pb.upcase!\n pb.reverse!\n puts str # => 'DLROW ,OLLEH'\n\n t = "yikes"\n pb.playback_on(t)\n puts t # => 'SEKIY'\n
Note [1]: For simplicity, we are assuming the "playback_on" message isn't recorded or passed on. Although in theory this is a hole in the spec, it doesn't really effect the litmus test.