Re: Trying to Load An Alias from Another Namespace into The Current Namespace
Hi, On 24 Okt., 04:00, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: This is what I did: - src/active-record/tns.clj (ns active-record.tns) (require '[active-record.user :as user]) (require '[active-record.charge :as charge]) You should not add a ns clause in this file. It acts like a C header would work. If you add a ns clause the namespace is changed again and the aliases are not done in the namespace which loads the file. Sincerely Meikel -- 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: Trying to Load An Alias from Another Namespace into The Current Namespace
Thanks for pointing this out. Adding the namespace declaration was exactly the reason why loading the file did not work in the first place. Now everything is working like a charm, and thanks to you I learnt yet another piece of the Clojure puzzle! Best regards, Stefan On Oct 24, 10:54 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 24 Okt., 04:00, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: This is what I did: - src/active-record/tns.clj (ns active-record.tns) (require '[active-record.user :as user]) (require '[active-record.charge :as charge]) You should not add a ns clause in this file. It acts like a C header would work. If you add a ns clause the namespace is changed again and the aliases are not done in the namespace which loads the file. Sincerely Meikel -- 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: Trying to Load An Alias from Another Namespace into The Current Namespace
Thanks for the great explanation. This really makes using the clj- record library much more comfortable! Stefan PS. Sorry for replying late. I could not get my VPN to work which meant Google Groups was blocked for me. On Oct 21, 7:47 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, you can't transfer aliases from one namespace to another. But as a workaround, you can create a file which contains the necessary commands: active-record/tables.clj: (require '[active-record.user :as user]) (require '[active-record.charge :as charge]) And then just load the file in the namespaces you want to use the tables. (ns active-record.program.core (:load tables)) ... --- (ns active-record.program.different-namespace (:load tables)) ... (You might have to use active-record/tables. Haven't used load in a while. But without .clj extension!) Sincerely Meikel -- 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: Trying to Load An Alias from Another Namespace into The Current Namespace
Hi Mikel, I tried your solution but am still not able to import the aliases from another namespace: This is what I did: - src/active-record/tns.clj (ns active-record.tns) (require '[active-record.user :as user]) (require '[active-record.charge :as charge]) - Clojure core file: src/active-record/program/core.clj (ns active-record.program.core) (load /active_record/tns) ;; Returns nil ;; I had to change 'active-record' to 'active_record' (user/create {:login my-login :first_name Jonas :last_name Rohl :password secret :email_address jo...@example.com}) ;; Evaluation throws an exception: ;; No such var: user/create ;; [Thrown class java.lang.Exception] ;; Same error message as before. (charge/create {:user_id 10, :amount_dollars 244 :amount_cents 91 :category meals :vendor_name Metro :date 2010-01-15}) ;; Evaluation throws an exception: ;; No such namespace: charge ;; [Thrown class java.lang.Exception] ;; Same error message as before. - I restarted Emacs after making the above changes to my code. Maybe it is just not possible to import aliases from another namespace? Stefan On Oct 21, 7:47 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, you can't transfer aliases from one namespace to another. But as a workaround, you can create a file which contains the necessary commands: active-record/tables.clj: (require '[active-record.user :as user]) (require '[active-record.charge :as charge]) And then just load the file in the namespaces you want to use the tables. (ns active-record.program.core (:load tables)) ... --- (ns active-record.program.different-namespace (:load tables)) ... (You might have to use active-record/tables. Haven't used load in a while. But without .clj extension!) Sincerely Meikel -- 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: Trying to Load An Alias from Another Namespace into The Current Namespace
I started Emacs again and now your solution is working! I have no idea why it did not work on the first restart but I am happy that I now can import aliases from another namespace. Thanks again for your help! Stefan On Oct 24, 10:00 am, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Hi Mikel, I tried your solution but am still not able to import the aliases from another namespace: This is what I did: - src/active-record/tns.clj (ns active-record.tns) (require '[active-record.user :as user]) (require '[active-record.charge :as charge]) - Clojure core file: src/active-record/program/core.clj (ns active-record.program.core) (load /active_record/tns) ;; Returns nil ;; I had to change 'active-record' to 'active_record' (user/create {:login my-login :first_name Jonas :last_name Rohl :password secret :email_address jo...@example.com}) ;; Evaluation throws an exception: ;; No such var: user/create ;; [Thrown class java.lang.Exception] ;; Same error message as before. (charge/create {:user_id 10, :amount_dollars 244 :amount_cents 91 :category meals :vendor_name Metro :date 2010-01-15}) ;; Evaluation throws an exception: ;; No such namespace: charge ;; [Thrown class java.lang.Exception] ;; Same error message as before. - I restarted Emacs after making the above changes to my code. Maybe it is just not possible to import aliases from another namespace? Stefan On Oct 21, 7:47 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, you can't transfer aliases from one namespace to another. But as a workaround, you can create a file which contains the necessary commands: active-record/tables.clj: (require '[active-record.user :as user]) (require '[active-record.charge :as charge]) And then just load the file in the namespaces you want to use the tables. (ns active-record.program.core (:load tables)) ... --- (ns active-record.program.different-namespace (:load tables)) ... (You might have to use active-record/tables. Haven't used load in a while. But without .clj extension!) Sincerely Meikel -- 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: Trying to Load An Alias from Another Namespace into The Current Namespace
Hi, you can't transfer aliases from one namespace to another. But as a workaround, you can create a file which contains the necessary commands: active-record/tables.clj: (require '[active-record.user :as user]) (require '[active-record.charge :as charge]) And then just load the file in the namespaces you want to use the tables. (ns active-record.program.core (:load tables)) ... --- (ns active-record.program.different-namespace (:load tables)) ... (You might have to use active-record/tables. Haven't used load in a while. But without .clj extension!) Sincerely Meikel -- 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