Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problem seeing fn metadata unless I eval or load a file
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jim Menard  
View profile  
 More options May 27 2010, 9:28 am
From: Jim Menard <jim.men...@gmail.com>
Date: Thu, 27 May 2010 09:28:16 -0400
Local: Thurs, May 27 2010 9:28 am
Subject: Problem seeing fn metadata unless I eval or load a file
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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe Grand  
View profile  
 More options May 27 2010, 9:59 am
From: Christophe Grand <christo...@cgrand.net>
Date: Thu, 27 May 2010 15:59:52 +0200
Local: Thurs, May 27 2010 9:59 am
Subject: Re: Problem seeing fn metadata unless I eval or load a file

Hi,

There is indeed a bug in how defn copy metadata from the var to the fn:
user=> (defn foo {:bar :baz} [] 42)
#'user/foo
user=> (meta #'foo)
{:ns #<Namespace user>, :name foo, :file "NO_SOURCE_PATH", :line 221,
:arglists ([]), :bar :baz}
user=> (meta foo)
{:ns #<Namespace user>, :name foo}
user=> (defn foo {:lucy :ethel} [] 43)
#'user/foo
user=> (meta #'foo)
{:ns #<Namespace user>, :name foo, :file "NO_SOURCE_PATH", :line 224,
:arglists ([]), :lucy :ethel}
user=> (meta foo)
{:ns #<Namespace user>, :name foo, :file "NO_SOURCE_PATH", :line 221,
:arglists ([]), :bar :baz}

There you see that the fn got the previous metadata and not the current. I'm
going to open a ticket.

Christophe


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jim Menard  
View profile  
 More options May 27 2010, 10:52 am
From: Jim Menard <jim.men...@gmail.com>
Date: Thu, 27 May 2010 10:52:27 -0400
Local: Thurs, May 27 2010 10:52 am
Subject: Re: Problem seeing fn metadata unless I eval or load a file
Christophe,

Thank you for your research and for opening the ticket.

Jim

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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe Grand  
View profile  
 More options May 28 2010, 3:56 am
From: Christophe Grand <christo...@cgrand.net>
Date: Fri, 28 May 2010 09:56:59 +0200
Local: Fri, May 28 2010 3:56 am
Subject: Re: Problem seeing fn metadata unless I eval or load a file

Actually it's a duplicate of ticket #270
http://www.assembla.com/spaces/clojure/tickets/270

--
Brussels, 23-25/6 http://conj-labs.eu/
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »