From e585ab65215e84cb5fa12fd84ffeee0421e56d07 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Wed, 14 Dec 2016 15:15:56 -0600 Subject: [PATCH] Document why the clerk-act-update-loop calls itself --- worlds/bricabrac.scm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/worlds/bricabrac.scm b/worlds/bricabrac.scm index d458327..84836fa 100644 --- a/worlds/bricabrac.scm +++ b/worlds/bricabrac.scm @@ -674,6 +674,7 @@ attend to.\n") (define clerk-return-to-slacking-text "The desk clerk enters and slams the door behind her.\n") + (define (clerk-act-update-loop clerk message) (define (tell-room text) (<- clerk (gameobj-loc clerk) 'tell-room @@ -681,6 +682,14 @@ attend to.\n") #:exclude (actor-id clerk))) (define (loop-if-not-destructed) (if (not (slot-ref clerk 'destructed)) + ;; This iterates by "recursing" on itself by calling itself + ;; (as the message handler) again. It used to be that we had to do + ;; this, because there was a bug where a loop which yielded like this + ;; would keep growing the stack due to some parameter goofiness. + ;; That's no longer true, but there's an added advantage to this + ;; route: it's much more live hackable. If we change the definition + ;; of this method, the character will act differently on the next + ;; "tick" of the loop. (<- clerk (actor-id clerk) 'update-loop))) (match (slot-ref clerk 'state) ('slacking -- 2.31.1