"Meikel Brandmeyer (kotarak)" <m...@kotka.de> writes:
> 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. 
>
> (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))


Yes, this works, and it's a good idea. My only criticism would be that
it's forcing me to do rather more with macros than I want -- the
"require-owl" step actually filters entities from the OWL file (not all
of them get vars) and transforms them (the legal name restrictions for
OWL are not the same as clojure). This also has implications for how
require-owl works; so

(def x "containing-A-and-B.owl")
(require-owl x)

won't work, while it would with a function.

I was a bit concerned this might hit the limit of the size of forms that
you see when load'ing code, but this doesn't happen -- I've just done
1,000,000 def statements in a single macro and it all seems happy.

Thanks for the feedback!

Phil

-- 
-- 
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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to