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