To add to that a little bit, this is what I found: #lang multi-file #file param.rkt #lang racket (provide my-param) (define my-param (make-parameter 'default))
#file param-test.rkt #lang racket (require "param.rkt") (define-namespace-anchor a) (parameterize ([current-namespace (make-base-namespace)] [error-print-width 4242] [my-param 'custom]) ;(namespace-attach-module (namespace-anchor->namespace a) "param.rkt" (current-namespace)) (namespace-require "param.rkt") (eval '(begin (printf "(error-print-width) = ~v\n" (error-print-width)) ;; 4242, not 250 (printf "(my-param) = ~v\n" (my-param)) ;; 'default ))) With the namespace-attach-module call commented out, this prints #file param.rkt #file param-test.rkt (error-print-width) = 4242 (my-param) = 'default But if I uncomment that line, I get: #file param.rkt #file param-test.rkt (error-print-width) = 4242 (my-param) = 'custom And if I move the namespace-attach-module call to after the (namespace-require "param.rkt"), I get this: #file param.rkt #file param-test.rkt . namespace-attach-module: a different module with the same name is already in the destination namespace module name: "/Users/Alex/Documents/DrRacket/param-thing/param.rkt" I hope that helps! Alex Knauth > On Aug 30, 2015, at 3:36 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote: > > The `make-base-namespace` function creates a new namespace, but it > attaches the `racket/base` instance of the current namespace to the new > one. The `error-print-width` parameter comes from `racket/base`, so > it's still the same parameter. > > You can use `namespace-attach-module` to attach "param.rkt" to the new > namespace, too, if you want its instance and parameter to be shared > across the namespaces. > > At Sun, 30 Aug 2015 12:04:30 -0700, Matthew Butterick wrote: >> In the example below, I'm curious about the reason for the difference >> between >> the behavior of the system parameter `error-print-width` and the custom >> parameter `my-param`. >> >> I understand why `my-param` doesn't take the parameterized value 'custom (= >> because `namespace-require` causes a fresh instantiation of "param.rkt" in >> the >> new namespace, which binds `my-param` with its default value). >> >> But if that's the case, then why does `error-print-width` accept the >> parameterized value? Why doesn't it get instantiated at its default value of >> 250 when the new namespace is made? >> >> >> ;; param.rkt >> #lang racket >> (provide my-param) >> (define my-param (make-parameter 'default)) >> >> >> ;; param-test.rkt >> #lang racket >> (require "param.rkt") >> (parameterize ([current-namespace (make-base-namespace)] >> [error-print-width 4242] >> [my-param 'custom]) >> (namespace-require "param.rkt") >> (namespace-require 'rackunit) >> (eval '(begin (check-equal? (error-print-width) 4242) ;; not 250 >> (check-equal? (my-param) 'default)))) >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Racket Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email >> to racket-users+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.