On Sun, Nov 15, 2009 at 8:28 PM, Rich Hickey <richhic...@gmail.com> wrote:

> On Sun, Nov 15, 2009 at 4:49 AM, ajuc <aju...@gmail.com> wrote:
> > On 15 Lis, 00:21, John Harrop <jharrop...@gmail.com> wrote:
> >> On Sat, Nov 14, 2009 at 3:03 PM, ajuc <aju...@gmail.com> wrote:
> >> > I have to install java one more time, when I try to start java -
> >> > server, I get:
> >> > Error: no `server' JVM at `F:\Program Files\Java\jre6\bin\server
> >> > \jvm.dll
> >>
> >> You need to use the one in F:\Program Files\Java\jdk6 instead.
> >>
> >> I'm surprised your IDE didn't select that one automatically. Mine
> >> (Enclojure) did.
> >
> > My IDE is waterfront, and it just starts java, and in my path the
> > first java was jre, I've changed that, problem solved, thanks.
> >
> > What's intresting, when I run the code in java -server, the difference
> > between using global, and using literal map expression in let got
> > bigger.
> >
> > Now its:
> > "Elapsed time: 555.810305 msecs" - with global
> > vs
> > "Elapsed time: 1091.399046 msecs" - with literal in let
> >
>
> Maps, vectors etc are evaluated. This is an important feature, as it
> allows you to e.g. create a vector by saying [x y], where x and y are
> non-constants.
>
> If you want a data structure to be unevaluated, then just quote it:
>
> '{ :a {[0 0] [0 :d], ...}


I should have thought of that.

But I was thinking that when the data structure does contain only constants,
the compiler could do something like this for you.

Even if you have e.g.

[[1 2] [x 4]]

the [1 2] part is unvarying and the resulting bytecode could be roughly
equivalent to (vector '[1 2] (vector x 4)).

In other words, basically just treat as quoted everything that won't change
in meaning by quoting it. The decision algorithm is basically

(defn data-structure? [x]
  (or (map? x) (set? x) (vector? x)))

(defn data? [x]
  (if (data-structure? x)
    (every? data? x)
    (or (number? x) (string? x) (keyword? x) (instance? Character x))))

though it might be useful to extend it to (list a b c) forms that evaluate
to static lists by effectively transforming these to '(a b c) as well.
(Probably less important, as one usually uses ' as a shortcut when creating
a constant list anyway. But cluttering up your vectors and maps with 's to
speed things up seems both ugly and avoidable with a few more compiler
optimization smarts.)

-- 
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