(make :button "The Button")
I have programs stored in c:\projects\klarity.clj
I have clojure stored in c:\clojure-1.2.1\clojure-1.21.
I am running c:\cljr\clj-installer-jar
I tried running
(ns clojure-1.2.1.clojure-1.2.1.src.clojure.core
(use [clarity.component :as c]))
(make :button "The Button")
What is namespace suposed to point to or access???
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Hi,
I don't understand your question, but...
> I think I understand namespace and then I don't!
> I try to run this example
>
> (ns examples.core
> (use [clarity.component :as c]))
The syntax of ns is
(ns examples.core
(:use [clarity.component :as c]))
Notice the colon preceeding the "use."
Bye,
Tassilo
Your email is not precise enough. What did you place in which files,
how were the files named, how were they stored relatively to some
"root" folder, and how did you start a REPL ?
2011/12/13 jayvandal <si...@ida.net>:
(ns examples.core
(:use clarity.component))
This will intern all the symbols in the clarity.component namespace
into examples.core, so you can use them as if they were defined in
examples.core in the first place: (make :button "the button")
This has the disadvantage of potential clashes, if a make function
existed in examples.core, it would be overwritten.
You can also say:
(ns examples.core
(:require clarity.component))
This makes the clarity.component namespace symbols available to you,
but you still have to fully qualify them: (clarity.component/
make :button "the button")
This is a bit long-winded, so you can alias the namespace to something
shorter:
(ns examples.core
(:require [clarity.component :as c]))
In which case your code becomes: (c/make :button "the button")
So you manage to be concise, but also you keep your namespaces tidily
separated :-)
Stathis
>> I think I understand namespace and then I don't!
>> I try to run this example
>>
>> (ns examples.core
>> (use [clarity.component :as c]))
>
> The syntax of ns is
>
> (ns examples.core
> (:use [clarity.component :as c]))
>
> Notice the colon preceeding the "use."
Oh, and of course Stathis is correct. `use' has no :as clause, so you
probably want to `require'.
(ns examples.core
(:require [clarity.component :as c]))
Bye,
Tassilo
;; you can call the function/macro make, by using the alias.
(c/make :button "The Button")
but if you don't want to use an alias and just introduce the vars from
the library to your namespace, the use use:
(ns examples.core
(:use clarity.component))
(make :button "The Button")
Notice that while using the form ns the internal calls to library like
use,require,import,... are actually keywords and not actual calls to
the forms use,require,import which you can use outside of the ns form.
I don't know if I explained myself well. It's been a while since I
dive into clojure, but I am coming back again. I would recommend
clojuredocs [http://clojuredocs.org/clojure_core/clojure.core/ns]