There has been some debate about this over time in the clojure mailing list.
I too regret from time to time the ability to organize my code "top-down"
without having to resort to "tricks" (declare).

I had suggested that unknown vars encountered during compilation could just
be "automatically declared" by default.
The debate has shown that there are at least 2 drawbacks to this approach:

  * you loose the ability to "catch up" problems at compile time: if you
misspelled a var, instead of explicitly reference a yet-to-be-defined var,
you're not helped by the compiler anymore.
  * in some areas, performant clojure code needs type hints to avoid
compiling bytecode which uses reflection. "auto-declaration" of
yet-to-be-defined vars associated with "seamless compilation" of code using
these "auto-declared" vars would automatically lead to suboptimal code where
the compiler cannot imply anything for the output ype of the auto-declared
var. The generated code would in average use more reflective calls.


2011/2/23 Mikhail Kryshen <mikh...@kryshen.net>

> On Tue, 22 Feb 2011 16:12:50 -0800 (PST)
> Jonathan Mitchem <jmitc...@gmail.com> wrote:
>
> > Hm, I see now.  Does Java work like that too?  (C# doesn't.)
>
> No.
>
> > Are there any plans for this to change in the future?  I can work with
> > it now, but it makes me uncomfortable.  It feels like a step
> > backwards.
> >
> > I fully understand if it was just a feature put on hold, just to get
> > the reader/compiler out there.  If it was a design decision, then
> > that's kind of different.
>
> This is probably by design. Loading or compiling clojure file implies
> evaluating all the forms it contains in order. You can do anything at
> compile/load time, not only define things.
>
> --
> Mikhail
>
> --
> 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 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

Reply via email to