Thanks - this solved the problem! Still not quite familiar with parameters I guess ;) And yes I simply copy/paste redefined code into REPL without clearing the old state - I will remember to do that going forward. <br><br>
Thanks,<br>yinso <br><br><div><span class="gmail_quote">On 4/16/07, <b class="gmail_sendername">Matthew Flatt</b> <<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
At Mon, 16 Apr 2007 16:30:36 -0700, "Yin-So Chen" wrote:<br>> (define dispatcher (make-parameter (make-hash-table 'equal))) ; run-time<br>> dispatcher...<br><br>`make-parameter' returns a value that acts like a procedure.
<br><br>> (define-syntax (register stx)<br>> (syntax-case stx ()<br>> ((_ key value)<br>> #'(hash-table-put! dispatcher key value))))<br><br>Use `(dispatcher)' instead of `dispatcher' to get the current dispatcher.
<br><br>> (define-syntax (dispatch stx)<br>> (syntax-case stx ()<br>> ((_ key args ...)<br>> #'((hash-table-get dispatcher key) args ...))))<br><br>Same here.<br><br>> (require bar) ; error = define-values: cannot change identifier that is
<br>> instantiated as a module constant: dispatcher<br><br>I get a different result:<br><br> hash-table-put!: expects type <mutable hash-table> as 1st argument,<br> given: #<primitive:parameter-procedure>; other arguments were: test
<br> #<procedure:test><br><br>For your error:<br><br>I think you must be using raw mzscheme and trying to re-define the<br>`dispatcher' module (as opposed to, say, using DrScheme with its "Run"<br>button that clears out old state before running program).
<br><br>Re-defining a module conflicts with certain optimizations that you'd<br>normally like the compiler to perform. To disable the optimizations and<br>allow module re-definition, use `(compile-enforce-module-constants
<br>#f)'.<br><br>Matthew<br><br></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.yinsochen.com">http://www.yinsochen.com</a><br>...continuous learning...