[racket] Advice: simulating stateful API in functional setting

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Jul 15 15:12:03 EDT 2011

On Jul 15, 2011, at 2:56 PM, Stephen Bloch wrote:

> I've experimented with a couple of ways to do that.  One way is to define (in my code, not visible to student code) a box named "world-pic", which is set-box!ed in "move" and "run-byob-world".  Another is to use just a plain variable and "set!", again hidden inside "move" and "run-byob-world".  Both seem to work for my toy examples so far; is there any advantage of one over the other? What subtle gotchas am I going to run into?  Is "a little bit of mutation" like "a little bit pregnant?"


I don't understand your solution. But if students cannot test their event handling functions in a functional style, then the answer to the last question is YES, you're pregnant. 

;; --- 

If so, the question is what you wish to accomplish with the library. If you're fine with teaching things that look like algebra but are actually imperative, join the club. Everyone else except us is doing it. 




Posted on the users mailing list.