Question: namespace-require

Hi

This works:

(let ((ns (make-base-namespace)))
 (parameterize ((current-namespace ns))
  (namespace-require '(file "tests.rkt"))))

This does not:

(let ((ns (make-base-namespace)))
 (namespace-require '(file "tests.rkt") ns))

require: unknown module
module name: "E:\a-simple-interpreter\tests.rkt"

How come?
From the docs I understand that if the first one works, the second one should work too.
Do I misunderstand the docs?
Thanks, Jos

I forgot to mention: DrRacket 8.3 BC, windows 10

2 Likes

You probably can use

(parameterize ([current-namespace ns])
  (namespace-require '(file "tests.rkt"))
  ...)

to replace?

This topic has been raised before in the old mailing list: https://www.mail-archive.com/racket-users@googlegroups.com/msg43291.html

I also logged this as an issue in the GitHub repo: https://github.com/racket/racket/issues/3307

My understanding is the same as mxork from GitHub: I only know that in most situations, current-namespace should be adjusted. From what @mflatt said, there appears to be a legitimate use case of not adjusting current-namespace but adjusting the second argument, but I do not know what this use case actually is.

2 Likes

Hi sorawee
Thanks, Jos