I'm currntly writing a build system based on clojure. On this way I defined a
record called Dependency:
(defrecord Dependency [aspect project runtime dev transitive]
...)
Lateron I try to create lib directories (lib/aspect, lib/project, lib/runtime
...). So it would be nice, if there is a possibility to express this based on
the above defined record keys - sth. like:
(doseq [mykey (keys Dependency)]
(ant/mkdir {:dir (str lib "/" (name mykey))}))
Is there a nifty way in clojure to access such "static record information"?
Kind regards,
Michael
--
Informatikbüro Jerger http://www.jerger.org
Zeppelinstr. 13, D-72770 Reutlingen
fon: +49-7121-578913 mob: +49-178-8189878
Am 05.04.2011 um 17:56 schrieb Michael Jerger:
> (doseq [mykey (keys Dependency)]
> (ant/mkdir {:dir (str lib "/" (name mykey))}))
>
> Is there a nifty way in clojure to access such "static record information"?
You can get it from instances of the record type.
user=> (defrecord Dependency [aspect project runtime dev transitive])
user.Dependency
user=> (doseq [mykey (keys (Dependency. 1 2 3 4 5))] (println mykey))
:aspect
:project
:runtime
:dev
:transitive
Otherwise, I'm not aware of such functionality other than reflection.
Sincerely
Meikel
Creating an temporal instance I would not denot as the upright way ...
> There is some ongoing work to make records more first-class, although I'm
> not sure if this feature will be included. See
> http://dev.clojure.org/display/design/defrecord+improvements
At the factory Part I totaly agree :-)
Not geting a first class Clojure object means, that it would not be possible,
to get my static info into and out of the records meta (^#)?
As straightforwad I expect to extend defrecord in order to put my information
into the record-types meta object und get the data out of this after ...
Would this work? Now? In fututre?
Kind regards,
M.Jerger