I completed a 0.1 version of a Clojure partial evaluator.  It consists
of a macro "par-eval" that analyses the form it is passed and replaces
all the sub-forms that can be reduced at macro-expand time with their
reduced versions, provided a printable form exists.

It can be obtained from git://github.com/larryjoe701/clojure-partialeval.git.
Please feel free to check it out and suggest improvements to its
function and form.

Function calls, macros, symbols, and most special forms are currently
handled.  Things for the next version include the remaining special
forms and collection types and possibly performance improvement for
loop/recur forms.  Down the line I plan to include a macro-generating-
macro that will allow for cross-function-level analysis (it is limited
to calling functions where all parameters are known).

A simple example:
(defn fibb [n]
  (if (< n 2)
  n
  (+ (fibb (dec n)) (fibb (dec (dec n))))))

(defn fibb30 [] (fibb 30))
(defn fibb30* [] (par-eval (fibb 30)))

(time (fibb30))
> "Elapsed time: 1353.797291 msecs"
> 832040

(time (fibb30*))
> "Elapsed time: 0.128627 msecs"
> 832040

-- Tim

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