Mon Mar 10 23:06:32 CET 2008

getting at the names..

got something that works:

;; Get to the exported names by requiring the module into an empty
;; namespace which has the base module attached to its registry.
(define (get-names path)
  (let ((n (make-base-empty-namespace)))
        ((current-namespace n))
      (namespace-require/expansion-time path))
    (namespace-mapped-symbols n)))

still stuck at some #%app problem further down the line, but the names
come out.

wait.. what a mess! the previous one did work, and the current one
doesn't (needs absolute paths).. get-module-code is ok.

this seems to be problematic:

(define (define-ns-tx stx)
  (syntax-case stx ()
    ((_ ns name val)
     (let ((mapped (ns-prefixed #'ns #'name)))
       #`(define #,mapped val)))))

the name created here 'mapped' is not recognized as a module-local one.

----------- broem.ss
#lang scheme/base
(provide foo)
(define-syntax (foo stx)
  (foo-tx stx))

----------- broem-tx.ss
#lang scheme/base
(provide foo-tx)
(define (foo-tx stx)
  #`(+ 1 2))

this gives
box> (require "broem.ss")
box> (foo)
broem-tx.ss:4:4: compile: bad syntax; function application is not allowed, because no #%app syntax transformer is bound in: (+ 1 2)

 === context ===
/usr/local/plt- loop

the thing that's missing here is the (require (for-template
scheme/base)) in broem-tx.ss

so it seems that now the remaining problems are because some names are
expanded to toplevel form because they are not visible somehow?
#lang scheme/base

------- lala.ss

 (for-syntax scheme/base))

(define foo 123)

(define-syntax (broem stx)
  (printf "compiling broem\n")
  #`(define lala #,'foo))


(provide foo broem lala)

that doesn't create the lala symbol.. why?