[plt-scheme] cannot modify module-bound variables
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.
Thanks,
yinso
On 4/16/07, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>
> At Mon, 16 Apr 2007 16:30:36 -0700, "Yin-So Chen" wrote:
> > (define dispatcher (make-parameter (make-hash-table 'equal))) ;
> run-time
> > dispatcher...
>
> `make-parameter' returns a value that acts like a procedure.
>
> > (define-syntax (register stx)
> > (syntax-case stx ()
> > ((_ key value)
> > #'(hash-table-put! dispatcher key value))))
>
> Use `(dispatcher)' instead of `dispatcher' to get the current dispatcher.
>
> > (define-syntax (dispatch stx)
> > (syntax-case stx ()
> > ((_ key args ...)
> > #'((hash-table-get dispatcher key) args ...))))
>
> Same here.
>
> > (require bar) ; error = define-values: cannot change identifier that is
> > instantiated as a module constant: dispatcher
>
> I get a different result:
>
> hash-table-put!: expects type <mutable hash-table> as 1st argument,
> given: #<primitive:parameter-procedure>; other arguments were: test
> #<procedure:test>
>
> For your error:
>
> I think you must be using raw mzscheme and trying to re-define the
> `dispatcher' module (as opposed to, say, using DrScheme with its "Run"
> button that clears out old state before running program).
>
> Re-defining a module conflicts with certain optimizations that you'd
> normally like the compiler to perform. To disable the optimizations and
> allow module re-definition, use `(compile-enforce-module-constants
> #f)'.
>
> Matthew
>
>
--
http://www.yinsochen.com
...continuous learning...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070416/a1322c93/attachment.html>