skime should be a fairly feature-complete pure-Python Scheme fallback for Schemepy after that. I’ve moved the source to the Schemepy repository. And now the backend wrapper (yes, pure-Python fallback still need backend wrapper) is also finished and most of the existing test cases have passed on that.
I committed almost nothing to the Thousand Parsec repository this week. That’s because I’m mainly working on skime — a pure-Python VM for Scheme. After one-week hard working, the basic shape of the VM is already there.
Although there are still many work (e.g. the macro system) to do before it can be a really useful VM, I decide to write a simple layer to fit the Schemepy API and run the benchmarks to see whether the time spent on a new fallback is worth.
I came across a very strange error when tweaking the skime compiler. I decided to use the more specific push_0 and push_1 instruction instead of the general push_literal when the literal is 0 and 1 respectively. However, after added this code, several test cases was broken immediately.
After examining the execution of the failing test cases, I found that I got a 0 when expecting a False. And I finally found the problem is that I use if literal == 0 to test whether I got a literal 0. But unfortunately, False == 0 (as well as True == 1) evaluates to True in Python. So there’s the bug.
I’m feeling rather surprised when I found False == 0. Yes, I know we use 0 to represent a false value in C, but I really don’t expect it to be in Python — such a high-level and duck-typing language. However, since it is already there, I have to remember.