Re: Intern a var from outside namespace

2012-10-17 Thread David Jacobs
I can see the potential problems with this pattern, but it also seems like a nice way to metaprogram things like controllers or models in a web app. (In non-web Clojure dev, I haven't ever run into this issue.) Will have to think about this some more... On Friday, October 12, 2012 at 11:33 AM,

Re: Intern a var from outside namespace

2012-10-12 Thread Arlen Christian Mart Cuss
On Friday, October 12, 2012 4:38:36 PM UTC+11, David Jacobs wrote: Having a map leads to pretty bad syntax for what I'm trying to do. That's why I want to metaprogram here. I want this ... (post/all api-key) … instead of this ... ((post/api :all) api-key) I'm not sure, but that

Re: Intern a var from outside namespace

2012-10-12 Thread Stuart Sierra
Sounds like a load-order issue. Make sure the code *creating* the namespaces/vars is loaded before the code *using* them. But better yet, just don't do it. :) -S -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Intern a var from outside namespace

2012-10-11 Thread David Jacobs
I would like to create function names programmatically. So far, I have code that works: (defn create [endpoints] (doseq [{:keys [action method url]} endpoints] (let [endpoint-fn (if (re-matches #.*/:id(/.*)? url) (fn [id session] (method

Re: Intern a var from outside namespace

2012-10-11 Thread Alan Malloy
On Thursday, October 11, 2012 9:03:38 PM UTC-7, David Jacobs wrote: I would like to create function names programmatically. So far, I have code that works: ... Where am I going wrong? David Sentence one. Don't do it that way: namespaces are not very good hashmaps, but hashmaps are

Re: Intern a var from outside namespace

2012-10-11 Thread David Jacobs
Note: I wrote this quickly. I should've taken the time to point out that the only difference between the first and second functions is the parameterized namespace, a-ns. When I say it doesn't work, I mean that accessing the created fn from a third ns throws a No such var exception. On

Re: Intern a var from outside namespace

2012-10-11 Thread David Jacobs
Having a map leads to pretty bad syntax for what I'm trying to do. That's why I want to metaprogram here. I want this ... (post/all api-key) … instead of this ... ((post/api :all) api-key) Why can an ns not be passed around like anything else? David On Thursday, October 11, 2012 at