Another question: can multiple VMs live inside the same process
boundary? So that code in VM1 (clojure-py) can call code in VM2 (pypy)
with no overhead.

There is also a third case, intermediate between optimizing vms for
algorithms and optimizing for full blown languages.

Think about implementing erlang-style actors. They send messages, have
the mailbox, and reduce a certain number forms when their turn comes.
Ignoring everything else in the language (the primitives in the actor
body that do the computation associated with message), this skeleton
system requires a certain kind of VM. Can we reify the clojure VM to
enable these properties?

It would be pretty impressive if one could parameterize the VM space,
and access different parts of that space within a contiguous clojure
program.



On Thu, Feb 9, 2012 at 7:43 PM, kovas boguta <kovas.bog...@gmail.com> wrote:
> This stuff is amazing.
>
> The big question for me is how this relates to macros. This sounds
> like a metaprogramming ability, where instead of changing the source
> code, you are changing the implementation layer.
>
> Here is a concrete use case I'm interested in: optimizing algorithms.
> I have some set of algorithms that needs such-and-such operations to
> be as fast as possible. Can I create a VM that is tailored for that?
> For example, tailor a VM around core.logic. Or would this be a silly
> thing to do?
>
>
> On Thu, Feb 9, 2012 at 7:26 AM, Timothy Baldridge <tbaldri...@gmail.com> 
> wrote:
>>> 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

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