Schemepy status: Guile and Python inter-callable

May 10, 2008 – 1:39 am

It’s the 2nd week of Schemepy. I’m glad to say that I have a roughly finished guile back-end now. All existing (including some newly added ones) passed without any problem. However, I’ve also make some non-trivial interface changes:

  • toscheme is an instance method instead of a static method of VM now.
  • fromscheme and type is instance methods of VM instead of SCM now.

Those changes (as long as some other interface change, like a Symbol class for Scheme symbols) make it impossible to run mithro’s oldguile back-end unless some non-trivial patches applied.

Both changes due to inter-converting a Scheme lambda and a Python callable. For example, you can convert a Scheme lambda to a Python callable and then call it:

func = vm.fromscheme(vm.eval("(lambda (x) (* x 2))"))
func(4) # => 8

But a Scheme lambda can’t be called independent of a VM, so the converted callable wrapper should remember the VM where the lambda was from. So fromscheme should be a method of VM instead of SCM, which is also unaware of the VM.

I was going along three lines at a time:

  1. Designing the interface.
  2. Writing the testcases.
  3. Writing the implementation.

And now I get a guile back-end with most of the core feature implemented and tested. All Python objects can be converted to a corresponding Scheme value and back again. Most native Scheme values can be converted to a corresponding Python value. A Python callable can be converted to a Scheme lambda — this is preferable to the oldguile’s way where it is only possible to register the callable as a named Scheme procedure.

Now there’re 3 tasks for me in a short-term:

  1. Finish the guile back-end: This includes adding profile support for VMs and various auxiliary functions to the VM. Though the core part of the back-end has been finished, this is still not an easy task. That’s because it is not just finishing the back-end, it is also finishing the interface which is much harder. The interface should remain stable after established.
  2. Testing: I’ll try to get/stole/borrow test-cases from other projects to do thorough test for my Schemepy with guile back-end as a Scheme implementation.
  3. Benchmarking: I’ll port the pyscheme to the new interface, write benchmarking test cases and run the benchmarks to compare the performance of the guile back-end and the schemepy back-end.

Both 2nd and 3rd task depend on the 1st one. So the 1st one should be finished at first. But the priority of the other two is not clear to me yet.

Post a Comment