I've given some functions metadata that I want to use elsewhere. My
problem is, I don't see the metadata I've added if I use or require
the namespace; I need to explicitly load the file (or eval the
function definitions manually in slime/swank) to see the metatada.
Here's some simple code that shows my problem. What am I doing wrong,
or not understanding about metadata?

;;; ================ src/ctest/funcs.clj ================
(ns ctest.funcs)

(defn
  #^{:wadl {:url "/f1" :method "GET" :doc "The f1 function."}}
  f1 [] 42)

(defn
  #^{:wadl {:url "/f2" :method "GET" :doc "The f2 function."}}
  f2 [] "eleventy-seven")

;;; ================ src/ctest/core.clj ================
(ns ctest.core
  (:use ctest.funcs))

(def wadl-meta (list (meta ctest.funcs/f1) (meta ctest.funcs/f2)))

;;; ================ in the repl (output wrapped) ================
user=> (use 'ctest.core)
nil
user=> ; I expect wadl-meta to contain the metadata added in funcs.clj
user=> ; but it does not. (Note; output is wrapped for this email)
user=> ctest.core/wadl-meta
({:ns #<Namespace ctest.funcs>, :name f1}
 {:ns #<Namespace ctest.funcs>, :name f2})
user=> ; The problem isn't with the definition of wadl-meta.
user=> (meta ctest.funcs/f1)
{:ns #<Namespace ctest.funcs>, :name f1}
user=> ; Now I load the file directly (or eval the defn in Emacs)
user=> (load-file "src/ctest/funcs.clj")
#'ctest.funcs/f2
user=> ; Look! I can see the metadata I defined now. WHY??????
user=> (meta ctest.funcs/f1)
{:ns #<Namespace ctest.funcs>, :name f1, :file "ctest/funcs.clj",
:line 3, :arglists ([]),
:wadl {:url "/f1", :method "GET", :doc "The f1 function."}}

Jim
-- 
Jim Menard, http://www.io.com/~jimm/

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to