aboutsummaryrefslogtreecommitdiffstats
path: root/README.rst
blob: 77ce6bc51e6f610c2f6ed059a9445613dae25f4a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
================
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.