Hi,
On 31 Okt., 05:30, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> It works with a literal for vecs:
>
> user=> (declare-init [[a 1] [b 2] [c 3]])
> #=(var user/c)
>
> But if I def the seq of seqs:
>
> user=> (def myvecs '[[a 1] [b 2] [c 3]])
> #=(var user/myvecs)
> user=> myvecs
> [[a 1] [b 2] [c 3]]
> user=> (declare-init myvecs)
> java.lang.IllegalArgumentException: Don't know how to create ISeq
> from: myvecs (Symbol) (NO_SOURCE_FILE:17)
For my understanding, the answer is: it is not possible to make
declare-init work that way. The declare-init call only sees the Symbol
myvecs. It doesn't resolve the var behind or whatever, since the
declare happens at compile time. Think (def myvecs
(terrible-computation)). However with literal vectors you actually get
the data structures themselves (containing symbols).
Why should (declare-init foo) resolve foo, but (declare-init [foo 5])
should not resolve foo?
Another question: Why not unify both?
(defmacro declare
[& vars]
`(do
~@(map (fn [x]
(if (vector? x)
`(def [EMAIL PROTECTED])
`(def ~x)))
vars)))
(declare foo [bar 5])
Using defvar instead of def from clojure.contrib.def
one even gets automatic docstrings.
Sincerely
Meikel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---