#lang scheme/base
(require
"tools.ss"
"ns-tx.ss" scheme/shared
scheme/provide-syntax
scheme/require-syntax
(for-template
scheme/base)
(for-syntax
scheme/base
syntax/stx
"ns-tx.ss"
))
(provide
(all-defined-out))
(define-provide-syntax ns-out ns-tx)
(define-require-syntax ns-in ns-tx)
(define-syntax ns ns-tx)
(define (ns-name ns [name '||])
(syntax->datum
(ns-prefixed (datum->syntax #f ns)
(datum->syntax #f name))))
(define (ns-name? ns)
(let* ((prefix (symbol->string (ns-name ns)))
(lp (string-length prefix)))
(lambda (sym)
(let* ((str (symbol->string sym))
(l (string-length str)))
(and (> l lp)
(string=? prefix (substring str 0 lp))
(string->symbol (substring str lp)))))))
(define (ns-mapped-symbols ns)
(let ((basename (ns-name? ns)))
(foldl
(lambda (sym collect)
(let ((it (basename sym)))
(if it (cons it collect) collect)))
'()
(namespace-mapped-symbols))))