Skip to content
This repository was archived by the owner on May 29, 2023. It is now read-only.
This repository was archived by the owner on May 29, 2023. It is now read-only.

Namespaces #3

@actondev

Description

@actondev

This issue is meant for organization/documentation purposes.

As s7 scheme doesn't have any separate module/namespace structure, coming from clojure I really missed this feature. So I cam up with a solution. See https://github.com/actonDev/s7-imgui/blob/b59927d/src/scheme/aod/ns.scm at the time of writing

Example usage:

(ns foo.bar)
;; sets the *ns* symbol in a new environment (let)
;; subsequent calls are evaluated in this environment
;; this is done by the repl from the c side. see
;; https://github.com/actonDev/s7-imgui/blob/b59927d2c875ff713aeddc8476973e8329e6f802/src/aod/s7/repl.cpp#L39

(ns-require foo.bar2)
(ns-require foo.bar3 :as bar3)
;; fully qualified namespace for calling
(foo.bar2/hi)

;; call with alias
(bar3/hi)

;; shows the current namespace
*ns*

;; the following are equivalent
;; --- BEGIN equivalent
(with-ns foo.bar2
	 (hi))

;; *nss* mnemonic: plurar of ns. NameSpaceS
(with-let (*nss* 'foo.bar2)
	  (hi))
;; this changes the *ns*
(ns foo.bar2)
(hi)
;; ---- END equivalent

;; WARNING
;; now foo.bar2/hi and bar3/hi are NOT available
;; to make them available we have to switch back:
(ns foo.bar)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions