[racket] world/universe update model (functional update redux), using the I/O monad for state

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Mon Dec 12 17:36:17 EST 2011

On Dec 12, 2011, at 2:52 PM, John Clements wrote:

> Here's a world/universe program written by one team in my class. It uses mutation all over the place:...
> Standard functional update observation:
> 
> This is definitely the natural way to write the program: certain keypresses correspond to certain changes in the state of the world, and the rest stays the same.
> 
> New part?
> 
> What if a world function could produce a list of "state change instructions"; something like (list (change world-volume 54) (change octave 34)). The caller of world can interpret this state change as a functional update. I see this as having an advantage over functional update in that the world doesn't require an explicit reference, and there's no chaining for multiple updates.

Which wouldn't actually help THIS program very much, since it only makes one state change in each case of the "cond".  But it would help other world/universe programs.

I would very much like to see SOME kind of functional-update feature bundled -- whether it comes along with define-struct, or with big-bang, doesn't matter much to me.


Stephen Bloch
sbloch at adelphi.edu




Posted on the users mailing list.