Re: Confusion with doc macro

2011-10-31 Thread Mark Rathwell
It uses (meta (var common/basic-logger)).

On Mon, Oct 31, 2011 at 2:28 PM, Sean Devlin francoisdev...@gmail.com wrote:
 I'm a bit confused by what the doc macro is doing.  Doesn't it simply
 work of the metadata of what is passed to it?

 I try this at the REPL:

 user= (doc common/basic-logger)
 -
 decorators.common/basic-logger
 nil
  nil
 nil

 For the following item:

 user= (meta common/basic-logger)
 {:ns #Namespace decorators.common, :name basic-logger, :file
 decorators/common.clj, :line 13, :arglists ([f]), :doc This is a
 very basic logging decorator.}

 Shouldn't I see something like this:

 user= (doc common/basic-logger)
 -
 decorators.common/basic-logger
 ([f])
  This is a very basic logging decorator.
 nil

 Any help would be great.

 --
 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

-- 
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


Re: Confusion with doc macro

2011-10-31 Thread Sean Devlin
Okay, then I need a hand with something then.  I'm trying to come up
with a macro that does the following:

(defmacro def-with-meta ...) - You supply this

(def-with-meta symbol init)

(= (meta (var symbol)) (meta init)) - True

Any suggestions folks?

Sean Devlin

On Oct 31, 2:59 pm, Mark Rathwell mark.rathw...@gmail.com wrote:
 It uses (meta (var common/basic-logger)).







 On Mon, Oct 31, 2011 at 2:28 PM, Sean Devlin francoisdev...@gmail.com wrote:
  I'm a bit confused by what the doc macro is doing.  Doesn't it simply
  work of the metadata of what is passed to it?

  I try this at the REPL:

  user= (doc common/basic-logger)
  -
  decorators.common/basic-logger
  nil
   nil
  nil

  For the following item:

  user= (meta common/basic-logger)
  {:ns #Namespace decorators.common, :name basic-logger, :file
  decorators/common.clj, :line 13, :arglists ([f]), :doc This is a
  very basic logging decorator.}

  Shouldn't I see something like this:

  user= (doc common/basic-logger)
  -
  decorators.common/basic-logger
  ([f])
   This is a very basic logging decorator.
  nil

  Any help would be great.

  --
  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

-- 
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


Re: Confusion with doc macro

2011-10-31 Thread Mark Rathwell
def already adds metadata on the symbol as metadata on the var.  Did
you need more than this (below)?

user (def ^{:doc foo} x [1 2 3])
#user/x

user (meta (var x))
{:ns #Namespace user, :name x, :doc foo, :line 1, :file NO_SOURCE_FILE}

user (doc x)
-
user/x
  foo
nil

user (defn ^{:doc foo foo} xx [] (println hello))
#'user/xx

user (meta (var xx))
{:arglists ([]), :ns #Namespace user, :name xx, :doc foo foo,
:line 1, :file NO_SOURCE_FILE}

user (doc xx)
-
user/xx
([])
  foo foo
nil


On Mon, Oct 31, 2011 at 4:08 PM, Sean Devlin francoisdev...@gmail.com wrote:
 Okay, then I need a hand with something then.  I'm trying to come up
 with a macro that does the following:

 (defmacro def-with-meta ...) - You supply this

 (def-with-meta symbol init)

 (= (meta (var symbol)) (meta init)) - True

 Any suggestions folks?

 Sean Devlin

 On Oct 31, 2:59 pm, Mark Rathwell mark.rathw...@gmail.com wrote:
 It uses (meta (var common/basic-logger)).







 On Mon, Oct 31, 2011 at 2:28 PM, Sean Devlin francoisdev...@gmail.com 
 wrote:
  I'm a bit confused by what the doc macro is doing.  Doesn't it simply
  work of the metadata of what is passed to it?

  I try this at the REPL:

  user= (doc common/basic-logger)
  -
  decorators.common/basic-logger
  nil
   nil
  nil

  For the following item:

  user= (meta common/basic-logger)
  {:ns #Namespace decorators.common, :name basic-logger, :file
  decorators/common.clj, :line 13, :arglists ([f]), :doc This is a
  very basic logging decorator.}

  Shouldn't I see something like this:

  user= (doc common/basic-logger)
  -
  decorators.common/basic-logger
  ([f])
   This is a very basic logging decorator.
  nil

  Any help would be great.

  --
  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

 --
 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

-- 
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


Re: Confusion with doc macro

2011-10-31 Thread Sean Devlin
No, I'm looking for a copy meta routine.

The mysterious defmeta macro does this, in one call.

(defmeta a map)

(= (meta (var a)) (meta map))

On Oct 31, 4:20 pm, Mark Rathwell mark.rathw...@gmail.com wrote:
 def already adds metadata on the symbol as metadata on the var.  Did
 you need more than this (below)?

 user (def ^{:doc foo} x [1 2 3])
 #user/x

 user (meta (var x))
 {:ns #Namespace user, :name x, :doc foo, :line 1, :file NO_SOURCE_FILE}

 user (doc x)
 -
 user/x
   foo
 nil

 user (defn ^{:doc foo foo} xx [] (println hello))
 #'user/xx

 user (meta (var xx))
 {:arglists ([]), :ns #Namespace user, :name xx, :doc foo foo,
 :line 1, :file NO_SOURCE_FILE}

 user (doc xx)
 -
 user/xx
 ([])
   foo foo
 nil







 On Mon, Oct 31, 2011 at 4:08 PM, Sean Devlin francoisdev...@gmail.com wrote:
  Okay, then I need a hand with something then.  I'm trying to come up
  with a macro that does the following:

  (defmacro def-with-meta ...) - You supply this

  (def-with-meta symbol init)

  (= (meta (var symbol)) (meta init)) - True

  Any suggestions folks?

  Sean Devlin

  On Oct 31, 2:59 pm, Mark Rathwell mark.rathw...@gmail.com wrote:
  It uses (meta (var common/basic-logger)).

  On Mon, Oct 31, 2011 at 2:28 PM, Sean Devlin francoisdev...@gmail.com 
  wrote:
   I'm a bit confused by what the doc macro is doing.  Doesn't it simply
   work of the metadata of what is passed to it?

   I try this at the REPL:

   user= (doc common/basic-logger)
   -
   decorators.common/basic-logger
   nil
    nil
   nil

   For the following item:

   user= (meta common/basic-logger)
   {:ns #Namespace decorators.common, :name basic-logger, :file
   decorators/common.clj, :line 13, :arglists ([f]), :doc This is a
   very basic logging decorator.}

   Shouldn't I see something like this:

   user= (doc common/basic-logger)
   -
   decorators.common/basic-logger
   ([f])
    This is a very basic logging decorator.
   nil

   Any help would be great.

   --
   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

  --
  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

-- 
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


Re: Confusion with doc macro

2011-10-31 Thread Mark Rathwell
 No, I'm looking for a copy meta routine.

 The mysterious defmeta macro does this, in one call.

 (defmeta a map)

 (= (meta (var a)) (meta map))

This will do what you want, but I would not advise using it:

(defmacro def-with-meta [symbol init]
  `(let [m# (meta ~init)]
 (def ~symbol ~init)
 (reset-meta! (var ~symbol) m#)
 (var ~symbol)))

Then:

  (= (meta (var symbol)) (meta init))  ;= true
  (= (meta (var symbol)) (meta symbol))  ;= true



 On Oct 31, 4:20 pm, Mark Rathwell mark.rathw...@gmail.com wrote:
 def already adds metadata on the symbol as metadata on the var.  Did
 you need more than this (below)?

 user (def ^{:doc foo} x [1 2 3])
 #user/x

 user (meta (var x))
 {:ns #Namespace user, :name x, :doc foo, :line 1, :file NO_SOURCE_FILE}

 user (doc x)
 -
 user/x
   foo
 nil

 user (defn ^{:doc foo foo} xx [] (println hello))
 #'user/xx

 user (meta (var xx))
 {:arglists ([]), :ns #Namespace user, :name xx, :doc foo foo,
 :line 1, :file NO_SOURCE_FILE}

 user (doc xx)
 -
 user/xx
 ([])
   foo foo
 nil







 On Mon, Oct 31, 2011 at 4:08 PM, Sean Devlin francoisdev...@gmail.com 
 wrote:
  Okay, then I need a hand with something then.  I'm trying to come up
  with a macro that does the following:

  (defmacro def-with-meta ...) - You supply this

  (def-with-meta symbol init)

  (= (meta (var symbol)) (meta init)) - True

  Any suggestions folks?

  Sean Devlin

  On Oct 31, 2:59 pm, Mark Rathwell mark.rathw...@gmail.com wrote:
  It uses (meta (var common/basic-logger)).

  On Mon, Oct 31, 2011 at 2:28 PM, Sean Devlin francoisdev...@gmail.com 
  wrote:
   I'm a bit confused by what the doc macro is doing.  Doesn't it simply
   work of the metadata of what is passed to it?

   I try this at the REPL:

   user= (doc common/basic-logger)
   -
   decorators.common/basic-logger
   nil
    nil
   nil

   For the following item:

   user= (meta common/basic-logger)
   {:ns #Namespace decorators.common, :name basic-logger, :file
   decorators/common.clj, :line 13, :arglists ([f]), :doc This is a
   very basic logging decorator.}

   Shouldn't I see something like this:

   user= (doc common/basic-logger)
   -
   decorators.common/basic-logger
   ([f])
    This is a very basic logging decorator.
   nil

   Any help would be great.

   --
   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

  --
  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

 --
 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

-- 
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