> Will clojure-py allow us to write our own VM's using clojure?

TL/DR: yes

Long version: RPython simply is a restriction on what bytecodes can do
in a given set of branches in a python program. So the cool thing
about RPython is, you define a main(argv[]) function, and then point
the PyPy translator at that function. Any code touched by that
function must conform to the RPython restrictions. But any code used
to generate that function can use standard Python.

So writing a RPython program is very much possible in clojure-py.

However the restrictions of RPython start to manifest themselves a bit
more in clojure-py. For instance most of clojure.core will be totally
useless to you. RPython states that "any function can take one and
only one type for each argument". This means that the following code
will not compile via RPython.

(defn foo [x] x)

(print (foo 1))
(print (foo "2"))

Now, the way we get around this is by wrapping everything:

(defprotocol W)

(deftype W_int [x]
    W
    (toString [self] x.__str__))

(deftype W_string [x]
    W
    (toString [self] x.__str__))

Now we can do what we want:

(defn foo [x] (.toString x))

(print (foo (W_int. 1)))
(print (foo (W_string "2")))

I'm hoping Macros and the like will help us get around allot of these
issues, but still, it's going to take some knowledge of how RPython
works to get clojure-py to work with it.

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