<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I'm trying to create a macro that creates a set of global function definitions where those functions share some common state. Basically, the intent is something like the following:<div><br></div><div><font class="Apple-style-span" face="'Andale Mono'">;;; doesn't work, creates local definitions instead of global ones</font></div><div><font class="Apple-style-span" face="'Andale Mono'">(let ((state (create-common-state)))</font></div><div><font class="Apple-style-span" face="'Andale Mono'"> (define (foo x) (use-common-state-one-way x state))</font></div><div><font class="Apple-style-span" face="'Andale Mono'"> (define (bar x) (use-common-state-another-way x state)))</font></div><div><br></div><div>I ended up making a macro that generates the following:</div><div><br></div><div><font class="Apple-style-span" face="'Andale Mono'">(define foo null)</font></div><div><font class="Apple-style-span" face="'Andale Mono'">(define bar null)</font></div><div><div><font class="Apple-style-span" face="'Andale Mono'">(let ((state (create-common-state)))</font></div><div><font class="Apple-style-span" face="'Andale Mono'"> (set! foo (lambda (x) (use-common-state-one-way x state)))</font></div><div><font class="Apple-style-span" face="'Andale Mono'"> (set! bar (lambda (x) (use-common-state-another-way x state))))</font></div><div><br></div><div>That works, but it seems a little clunky. Is there a better way?</div><div><br></div><div>Thanks,</div><div>Jeff de Vries</div><div><br></div></div></body></html>