Re: Clojure compiletime vs runtime

2014-04-15 Thread Luc Prefontaine
Compilation is mandatory before executing anything. By default when code is loaded it's executed. That's how a Lisp behaves. If you want to isolate compilation, from execution, you can use AOT (ahead of time compilation). You would use this to deliver compiled code w/o source code, make sure th

Re: Clojure compiletime vs runtime

2014-04-15 Thread Andrew Chambers
I only noticed it because I was trying to write a macro which expands to multiple def calls. This requires the def's to be inside a do block, which made me question a whole lot about how the AOT compiler works. On Tue, Apr 15, 2014 at 11:05 PM, Phillip Lord wrote: > > You need to distinguish be

Re: Clojure compiletime vs runtime

2014-04-15 Thread Phillip Lord
You need to distinguish between "compiled" and "aot compiled to byte code". As far as I know, all forms are compiled before they are executed. So, if you type: (+ 1 1) it is first compiled to bytecode, and then run. It's not executed at compile time at all; rather when it is evaluated, it is co

Re: Clojure compiletime vs runtime

2014-04-15 Thread Andrew Chambers
Why are the toplevel forms which arent macros executed at compile time? For example Lua can be compiled to bytecode without executing its top level calls. On Tue, Apr 15, 2014 at 9:04 PM, Softaddicts wrote: > Ahem :) > > a) The fn x does not exist in the universe until you call foo, hence you >

Re: Clojure compiletime vs runtime

2014-04-15 Thread Softaddicts
Ahem :) a) The fn x does not exist in the universe until you call foo, hence you cannot expect the compiler to known anything about it if it's not called before making any reference to x. b) If you refer to x at the top level (the "universe" above :) before defining it, obviously it

Re: Clojure compiletime vs runtime

2014-04-14 Thread Andrew Chambers
Forgive me, the first example was meant to be The following code wont compile: (defn y[]) ((x)) (defn x [] nil) On Tuesday, April 15, 2014 4:39:59 PM UTC+12, Andrew Chambers wrote: > > Is there an explanation of how clojure deals with scoping and its static > checking. It seems to be a hybrid o