Hi, Am 20.12.2008 um 17:25 schrieb chris:
I am unclear as to the difference between refer, import use, and require.
require loads a lib from the classpath. The you can
access the public names of the lib's namespace via
full qualified names.
(require 'foo.bar)
(foo.bar/baz "Hurray")
refer let's you refer an already require'd namespace,
so you can access the names directly.
(require 'foo.bar)
(refer 'foo.bar)
(baz "Hurray")
use is basically a require followed by a refer.
(use 'foo.bar)
(baz "Hurray")
alias can be used to introduce an alias for a require'd
namespace.
(require 'foo.bar)
(alias 'fb 'foo.bar)
(fb/baz "Hurray")
import is a "refer for classes". It is a direct translation
of the Java import.
w/o import:
(new java.io.BufferedReader ...)
w/ import:
(import '(java.io BufferedReader))
(new BufferedReader ...)
However these are all very low-level. The preferred
way is to use the :keyword notation in the ns macro.
(ns my.name.space
(:require
[foo.bar :as fb])
(:import
(java.io BufferedReader)))
(fb/baz "Hurray")
(new BufferedReader ...)
There are lots of other options :exclude, :only, ...
Hope this helps.
Sincerely
Meikel
smime.p7s
Description: S/MIME cryptographic signature
