================ define-namespace ================ DEFINE-NAMESPACE is an R5RS macro that implements a subset of R7RS's DEFINE-LIBRARY. ----- Usage ----- Syntax:: (define-namespace namespace-name [DECL list]) DECL ::= (define defbody ...) | (export [identifier list]) | (import [IMPORTSPEC list]) IMPORTSPEC ::= (only ns [identifier list]) ::= (rename ns [(identifier identifier) list] (import-from-namespace [IMPORTSPEC list]) Example:: (define-namespace ns (define param 5) (define (f x) (* 5 x)) (export f)) (define-namespace ns2 (import (rename ns (f g))) (define (f x) (* 5 (g x))) (export f)) (import-from-namespace (only ns2 f)) (f 17) --------------------- Differences from R7RS --------------------- * There are only EXPORT, IMPORT, and BEGIN statements. * DEFINE-SYNTAX does not work. * EXPORT statements must occur after DEFINEs. * IMPORT only allows for ONLY and RENAME clauses. * Namespace names are identifers, not lists. * Namespaces are Scheme objects. * To import outside of namespaces, use IMPORT-FROM-NAMSPACE, not IMPORT. -------- Examples -------- * ``srfi/srfi-1.scm`` is the reference implementation of SRFI-1 wrapped in a namespace. * ``examples/aatree.scm`` is an imperative binary tree implementation. ``examples/test-aatree.scm`` uses SRFI-64 to run some tests on the implementation. Requires SRFI-9 and SRFI-11 (``let-values``).