Re: Unit tests for a #lang implementation

Matthew Flatt <mflatt-sDh8Nw2yj/[email protected]>
Newsgroups gmane.comp.lang.racket.user,gmane.lisp.scheme.plt
Message-ID <[email protected]>
I forgot to explain why this fails:

At Fri, 25 Aug 2017 14:59:14 +0200, Konrad Hinsen wrote:
> (eval-syntax
>   (parameterize ([read-accept-lang #t]
>                  [read-accept-reader #t])
>     (read-syntax "test-module"
>                  (open-input-string "#lang 
> scribble/base\n@section[Introduction]")))
>   (module->namespace 'racket/base))
> 
> only says
> 
> ; test-module::1: module: unbound identifier;
> ;  also, no #%app syntax transformer is bound
> ;   at: module
> 
> although both module and %app are defined in racket/base.

The `eval-syntax` function refrains from adding any scopes to the given
syntax object before trying to expand it. So, it doesn't add the scope
for the namespace's top-level bindings (unlike `eval`, which does add
that scope before trying to expand). That's why `#%app` and `module`
are not bound when trying to expand the syntax object in the above
example; the syntax object has no scopes and therefore no bindings.

The `check-module-form` function adds a suitable scope to the `module`
binding in the given syntax object. It would work just as well to not
use `check-module-form` and to use `eval` so that the `module` binding
is taken from the namespace.

-- 
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.