> I'm seeing a RPython test in the examples. Can Clojure-Py emit RPython code
> from my Clojure code? If so, that'd be really great we could go Clojure ->
> RPython -> C -> Native
>
> I guess it probably isn't since I imagine that laziness uses generators
> which aren't well supported under RPython but if it did use make RPython
> code, it'd be really awesome.

Well that's the one part where Clojure and Python diverge. Clojure-py
does not use Python's generators. This is because Python's generators
are mutable. So that actually wont' be a problem.

What is a problem though, is the way Clojure-py currently accesses
vars. Consider the following:

(+ 1 2)

In Clojure-py we'd compile this as

LOAD_CONST #user/+
LOAD_ATTR deref
CALL_FUNCTION 0
LOAD_CONST 1
LOAD_CONST 2
CALL_FUNCTION 2

It's this first line that causes the RPython translator to blow up.
Calling LOAD_CONST and supplying a complex type like VAR is more than
it can handle. Now it just so happens this is completely acceptable in
normal Python code, so that's where the issue is.

My plan is to abstract this a bit. I plan on providing global vars
that allow the user to specify how the current code is bound. For
instance, if #user/+ is a static var, there's no reason to deref it
every single time, since it will never change. However, dynamic vars
need to be deref'ed, and RPython vars need to use pure LOAD_GLOBAL,
LOAD_ATTR calls. The plan then is to provide the Clojure-py backend
with a simple (deref this var) object that will allow the compiler to
on-the-fly decide how certain pieces of code are called.

It just so happens that once this is implemented, it will also allow
us to serialize clojure code using CPickle. This should allow us to
drop the startup times of Clojure-py down into the <1sec range.

And actually, being able to run Clojure code on RPython is a personal
goal for me. It's probably one of the biggest motivations for me to
actually start this project. So as I find time, I do plan on exploring
this, and building up a good macro/function library to allow users to
experiment with RPython a bit more easily.

Timothy

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