Hi,
Am Montag, 23. September 2013 11:37:10 UTC+2 schrieb Phillip Lord:
>
> So, now I can refer to an OWL file in
> exactly the same way as if it were written in Clojure.
>
Ok. So, it is correct to think of this as a fancy require-owl, isn't it?
Then this means you read the OWL files at compilation time of your code.
But that means, that a macro expanding to a series of def will do the job.
There is no need for a require. I could imagine something like this (a lot
of pseudo-code there):
(defmacro defowl
[sym init]
`(do
(def ~(with-meta sym {:owl true}) ~init)
(tawny.owl/run-intern-hook (var ~sym))
(var ~sym)))
(defn owl-entry-definition
[{:keys [sym init]}]
`(defowl ~(further-process sym) ~init))
(defmacro require-owl
[file]
(let [owl-entries (owl-seq (io/reader file))]
`(do ~@(map owl-entry-definition owl-entries))))
; Usage
(require-owl "containing-A-and-B.owl")
(defn use-classes
[]
(do-something-owly A B))
This could be further cleaned up, but I think you get the idea. (One could
add for example namespace handling for owl files or provide it as an option
to require-owl, use with-open &c. &c.)
For testing, resolve and ns-resolve are your friend:
(deftest loading-owls
(require-owl "some-dummy-A.owl")
(let [dummy-A (resolve 'A)]
(is (not (nil? dummy-A)))
(is (= @dummy-A some-reference-A))))
Hope that helps.
Meikel
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.