4th week of Schemepy: the not-so-friendly API of mzscheme

May 23, 2008 – 6:55 pm

There’s not too much done in this week for Schemepy. At first I was trying to port libtpclient-py from pyscheme to Schemepy. However, the code base of libtpclient-py is not too big, and I only found little code that used pyscheme. I thought I should learn the basic behavior of the lib and the client before I start hacking it. Unfortunately, I have no idea of what 4x game is. I tried several times but still not figured out how to play a TP game.

Then I decide to work on another backend. Maybe guile is the most easy one because it is designed to be embedded into another program. Other Scheme implementations are not so easy when it comes to embedding. By comparing mzscheme with chicken, I decided to work on mzscheme first. Both are great Scheme implementations, but I think the C interface of mzscheme is not so friendly.

I think one of the most difficult part of supporting a backend is to have the garbage collector of Python and Scheme to co-exist peacefully. Mzscheme has two memory models (CGC and 3m) which make things harder. And the implementation is a little complicated in my opinion. For example, the number system is complex and not easy to work with; there seems to be 2 (or 3) types of strings in the implementation — dealing with strings is another bother task because C, who is the glue between Scheme and Python, is not permitted to have null character in the middle its string. After searching through the document and the header files, I still not found the interface to get the length of a string. :(

However, I managed to set up the basic skeleton of the backend. Some primitive test cases (like test_int.py, test_bool.py and test_complex.py etc.) have passed on this backend.

  1. 2 Responses to “4th week of Schemepy: the not-so-friendly API of mzscheme”

  2. Sorry I have not been around this week. I have just started a job at Google Australia and am now in the USA doing training.

    Lets sit down on IRC sometime, I can give you a tutorial on how to play and show you where/when pyscheme is being used. The scheme code is being downloaded from the server so it might be a little confusing.

    Will send you an email too.

    By Mithro on May 23, 2008

  3. @Mithro,
    Cool!

    By pluskid on May 24, 2008

Post a Comment