Skip to content
Ramil Farkhshatov edited this page Nov 13, 2012 · 2 revisions

Definitions

Top-level form: namespace

(namespace Name Exceptions
   Code)

Name is a symbol representing the name. Exceptions is a list of exclude prefixes.

All other symbols in Code excluding cases listed below have prefix Name-, where Name is a namespace name.

  • System functions (define, +, reverse, ...) are left untouched.
  • Symbols with prefixes X- where X is an element of Exceptions list are left untouched.

Example:

(namespace mod-one- [mod-zero-]
   [a b c mod-zero-a mod-two-b])

Result:

[mod-one-a mod-one-b mod-one-c mod-zero-a mod-one-mod-two-b]

Form: subnamespace

(subnamespace prefix exceptions
  Code)

prefix is a symbol, representing namespace within the scope of the form. prefix is attached to symbols within the scope of the form after namespace name prefix. exceptions is a list of symbols, which are not prefixed neither by namespace name prefix nor subnamespace prefix.

Example:

(namespace mod1 []
  (subnamespace ns1 [d]
    [a b c d]))

Result:

[mod1-ns1-a mod1-ns1-b mod1-ns1-c d]

Form: namespace-synonyms

(namespace-synonyms (name alias
                     name1 alias1 ... )
  Code)

name is a symbol, which represents namespace original name, and alias is a symbol, representing namespace alias. In all symbols, beginning with alias-, alias- will be replaced by name-.

Example:

(namespace mod1 []
  (subnamespace ns1 [a b]
    (namespace-synonyms (name1 n1
                         name2 n2)
      [a b c d n1-e n2-f])))

Result:

[a b mod1-ns1-c mod1-ns1-d name1-e name2-f]

Form: from-namespace

(from-namespace name symbols
  Code)

name is a symbol, which represents namespace name or alias (defined in upper namespace-synonym), and symbols is a list of symbols, which will be prepended by original namespace name.

Example:

(namespace mod1 []
  (subnamespace ns1 [a b]
    (from-namespace name1 [e f]
      [a b c d e f])))

Result:

[a b mod1-ns1-c mod1-ns1-d name1-e name1-f]

Form: not-in-namespace

(not-in-namespace
  Code)

not-in-namespace discards all symbols prefixing rules (introduced by upper namespace, subnamespace etc, forms) within its scope.

Example:

(namespace mod1 []
  (subnamespace ns1 [a b]
    (from-namespace name1 [e f]
      [a b c d e f (not-in-namespace e)]
      (not-in-namespace [a b c d e f]))))

Result:

[a b mod1-ns1-c mod1-ns1-d name1-e name1-f e]
[a b c d e f]