[plt-scheme] Evaluation Across Modules (or Namespaces?)

From: Williams, M. Douglas (M.DOUGLAS.WILLIAMS at saic.com)
Date: Sun Jul 16 14:49:22 EDT 2006

>> And get this when I run it:
>> 
>> (app(t1 2) = 4
>> (my-f2 2) = 4
>> . . a.ss::436: reference to undefined identifier: my-f2
>seems to only work for identifiers (like *) in the mzscheme
>> namespace.
>
>I don't think I understand your whole problem, but you might make
>progress by using syntax objects instead of plain symbols and pairs:
>
>(module a mzscheme
>  
>  (provide (all-defined))
>  
>  (define-struct s (args body f))
>  
>  (define-syntax def
>    (syntax-rules ()
>      ((d name args body ...)
>       (define name (make-s #'args
>                            #'(body ...)
>                            #f)))))
>  
>  (define (act an-s)
>    (set-s-f! an-s
>              (eval #`(lambda #,(s-args an-s)
>                       #,@(s-body an-s)))))
>  
>  (define (app an-s . args)
>    (apply (s-f an-s) args))
>  
>  (define (my-f3 x) (* x x))
>  
>  )
>
>
>Matthew

Why does it also work when the args are not syntax-quoted?  That is, the
only difference being 'args instead of #'args in the make-s call within def.
Is it because the symbols 'exist' in the invoking module?

Doug



Posted on the users mailing list.