http://onclojure.com/2010/02/17/managing-namespaces
There are a lot of good ideas in there, and right now I'd like to talk specifically about the proposed :like & :clone clauses. I have a bit of a different approach.
Supposed we add a new project file, namespace_config.clj. It would be a basic rules engine for configuring namespaces. I'm thinking there would be a macro, extend-ns, that is roughly defined as follows. The exact implementation needs work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro extend-ns | |
[pred & ns-clauses] | |
(if (pred a-ns) | |
(let [clauses (apply hash-map ns-clauses)] | |
`(do | |
(import ~@(:import clauses)) | |
(use ~@(:use clauses)) | |
(require ~@(:require )))))) |
This lets us set up a series of predicates & resulting actions that would be applied to each ns in the project. Everything would be done in one central location, so (hopefully) that would cut down on maintenance.
Could you show an example of what you're proposing "in action" ?
ReplyDeleteSure, I'll add that later today. For now, think RailTies (sorry for non-ruby backgrounds).
ReplyDeleteI'd also like to see an example. In particular, I wonder what the predicate function would look like in practice. A priori, I would expect the applicability of a rule to a namespace defined in the namespace rather than in the rule, so I am wondering what you had in mind.
ReplyDeleteStill working on this, it's way harder than I thought. I'll keep you posted.
ReplyDelete