philipbohun.com

Glojure by Example: Namespaces

A file that is part of a program starts with ns. The name becomes the current namespace, and :require loads another namespace under an alias. A script with no ns form is loaded into clojure.core, which is fine for a one-off example and a poor place to leave real definitions.

(ns example.greet
  (:require [clojure.string :as string]))

(defn shout [s]
  (string/upper-case s))

(println (shout "glojure"))
(println (str *ns*))

*ns* is the current namespace.

$ glj namespaces.glj
GLOJURE
example.greet

Next example: Records.