Sha256: 26e139c12f5012ebabf237c436eb44b8765e4ab04ba5865c044fc8577350be54

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

;; creates a private namespace for support functions for one or more explicitly exported/public functions
;;
;; (module foo
;;   (def h ...)
;;   (def u ...)
;;   (export bar (x y) (h u x y)))
;;
;; results in 'foo/bar being universally available, but 'h and 'u are visible only within the module and override
;; any other 'h or 'u defined elsewhere, in the scope of the module.
(mac module (module-name . forms)
  (let private-names nil
    (let module-forms
         { def        (fn (name args . body)
                          (push nil  private-names)
                          (push name private-names)
                          `(assign ,name (fn ,args ,@body)))
           export-def macs.def
           export     (fn (name args . body)
                          `(export-def
                            ,(sym (+ (to-string module-name) "/" (to-string name)))
                            ,args
                            ,@body)) }
      (let module-body (pre-compile-each module-forms forms)
        `(with (,@private-names) ,@module-body)))))

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nydp-0.6.0 lib/lisp/core-039-module.nydp
nydp-0.5.1 lib/lisp/core-039-module.nydp
nydp-0.5.0 lib/lisp/core-039-module.nydp
nydp-0.4.6 lib/lisp/core-039-module.nydp
nydp-0.4.5 lib/lisp/core-039-module.nydp