Re: two pass compilation, intern and def

2013-09-23 Thread Phillip Lord
"Meikel Brandmeyer (kotarak)" writes: > you are right. require-owl also works as a function: > > (defn require-owl > [file & {nspace :namespace :or {nspace *ns*}}] > (with-open [rdr (io/reader file)] > (doseq [entry (owl-seq rdr) > :let [entry-name (translate-name (:name entry)

Re: two pass compilation, intern and def

2013-09-23 Thread Meikel Brandmeyer (kotarak)
Hi, you are right. require-owl also works as a function: (defn require-owl [file & {nspace :namespace :or {nspace *ns*}}] (with-open [rdr (io/reader file)] (doseq [entry (owl-seq rdr) :let [entry-name (translate-name (:name entry))]] (intern nspace entry-name (:init entr

Re: two pass compilation, intern and def

2013-09-23 Thread Phillip Lord
"Meikel Brandmeyer (kotarak)" 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

Re: two pass compilation, intern and def

2013-09-23 Thread Meikel Brandmeyer (kotarak)
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 compilat

Re: two pass compilation, intern and def

2013-09-23 Thread Phillip Lord
"Meikel Brandmeyer (kotarak)" writes: > don't get me wrong: I don't want to discuss away your use case! But I don't > understand it, yet. After your calling intern, do you compile other code > referencing the created Vars? If no: why do you need Vars? If yes: why > don't you just generate cod

Re: two pass compilation, intern and def

2013-09-23 Thread Meikel Brandmeyer (kotarak)
Hi, don't get me wrong: I don't want to discuss away your use case! But I don't understand it, yet. After your calling intern, do you compile other code referencing the created Vars? If no: why do you need Vars? If yes: why don't you just generate code with a def and compile it? Meikel -- --

Re: two pass compilation, intern and def

2013-09-23 Thread Phillip Lord
Gary Verhaegen writes: > Well, do actually means "execute all of the following forms, sequentially, > at this point". It seems to me that the position of saying this also works > when "this point" is the top-level is sensible. Perhaps; what does not seem sensible is that it *only* works at top-

Re: two pass compilation, intern and def

2013-09-21 Thread Gary Verhaegen
Well, do actually means "execute all of the following forms, sequentially, at this point". It seems to me that the position of saying this also works when "this point" is the top-level is sensible. I do not know what your actual use-case is, but, as Meikel said, it seems a bit strange to use inter

Re: two pass compilation, intern and def

2013-09-20 Thread Phillip Lord
Meikel Brandmeyer writes: > 2013/9/20 Phillip Lord >> (def bob3 3) >> >> introduces a new symbol, I am struggling to see why >> >> (intern 'user 'bob3 3) >> >> cannot be recognised similarly. >> > > Because intern happens at runtime. It's a normal function. The above intern > call is easily trans

Re: two pass compilation, intern and def

2013-09-20 Thread Meikel Brandmeyer
Hi, 2013/9/20 Phillip Lord > > (def bob3 3) > > introduces a new symbol, I am struggling to see why > > (intern 'user 'bob3 3) > > cannot be recognised similarly. > Because intern happens at runtime. It's a normal function. The above intern call is easily translated to the def. intern is only i

Re: two pass compilation, intern and def

2013-09-20 Thread Phillip Lord
Gary Verhaegen writes: > As Meikel said in his previous mail, 'do' at the top-level is treated > specially: each form is treated as a separate top-level form. This is, for > example, useful for defining a macro that defines multiple functions. I'd be interested to see an example, where this beh

Re: two pass compilation, intern and def

2013-09-20 Thread Meikel Brandmeyer
Not that I am aware of. do is special to allow macros expanding into several defs where the later depend on the former. (defmacro foo [a b] `(do (def ~a 5) (def ~b ~a))) This is necessary, because a macro can only return one form. And the name resolution for ns is special-cased, IIRC

Re: two pass compilation, intern and def

2013-09-19 Thread Colin Fleming
This is interesting - are there any other cases where forms are treated specially at top-level? On 20 September 2013 10:01, Gary Verhaegen wrote: > As Meikel said in his previous mail, 'do' at the top-level is treated > specially: each form is treated as a separate top-level form. This is, for

Re: two pass compilation, intern and def

2013-09-19 Thread Gary Verhaegen
As Meikel said in his previous mail, 'do' at the top-level is treated specially: each form is treated as a separate top-level form. This is, for example, useful for defining a macro that defines multiple functions. So what Meikel was really trying to say is that the reason (do (intern 'user 'bob3

Re: two pass compilation, intern and def

2013-09-19 Thread Phillip Lord
"Meikel Brandmeyer (kotarak)" writes: > Clojure's compile unit is one toplevel form. Therefore > > (intern 'user 'bob3 3) > bob3 > > works, while > > (is (do (intern 'user 'bob2 2) bob2)) > > does not, because the former are two compilation units while the latter is > only one. (Note: (do ...) i

Re: two pass compilation, intern and def

2013-09-19 Thread Meikel Brandmeyer (kotarak)
Hi, Clojure's compile unit is one toplevel form. Therefore (intern 'user 'bob3 3) bob3 works, while (is (do (intern 'user 'bob2 2) bob2)) does not, because the former are two compilation units while the latter is only one. (Note: (do ...) is a special case. (do (intern 'user 'bob3 3) bob3)

two pass compilation, intern and def

2013-09-19 Thread Phillip Lord
In a clean repl, try the following... (use 'clojure.test) (is (do (intern 'user 'bob2 2) bob2)) (is (do (def bob3 3) bob3)) The first is form breaks with a "Unable to resolve symbol" error at the compilation stage. The second one, on the other hand is quite happy. Now, I guess what is happeni