[racket-dev] [plt] Push #23663: master branch updated

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Wed Oct 5 15:44:40 EDT 2011

On 10/05/2011 01:13 PM, ntoronto at racket-lang.org wrote:
> ntoronto has updated `master' from e1a82481d1 to 32d789d4f8.
>    http://git.racket-lang.org/plt/e1a82481d1..32d789d4f8
>     ; fit-int : (number* ->  number) (list-of (symbol number)) (list-of (vector number [number] number number)) ->  fit-result
>     (define (fit-int function guesses data)
> +    ;; Require dynamically so the rest of 'plot' still works without libfit:
> +    (define fit-internal (dynamic-require 'plot/deprecated/fit-low-level 'fit-internal))
>       (let* ((independent-vars (- (procedure-arity function) (length guesses)))
>              (f-of-x-y (cond
>                          [(= 1 independent-vars)

Be careful with dynamic-require; it uses (current-namespace), which is 
not necessarily the same namespace that the enclosing module was loaded 
in. Specifically, you might get a different module registry, which can 
lead to multiple module instantiations, which can lead to problems with 
generative structs, etc.

Also, with plain dynamic-require, if you build an executable ("raco 
exe") it probably won't include the dynamically-required module.

I recommend using lazy-require (from unstable/lazy-require) instead. It 
handles both the namespace issue and the "raco exe" issue automatically.


Posted on the dev mailing list.