[phemlock-devel] Hemlock string tables

Robert Strandh strandh at labri.fr
Tue Aug 3 11:31:24 UTC 2004


Hello,

For a few days, I have been looking around at various parts of the
code for Portable Hemlock.  Much code is quite easy to understand
and/or sufficiently documented that I can understand it right away.  

Then, I came across `table.lisp' in the `core' directory.  This
library makes it possible to do strange completions (like some
versions of CLIM can do) where strings like "l th d t" can be expanded
to "Load The Damned Thing".

It took me the better part of a working day to understand what on
earth it was supposed to do, and how it accomplished it.  Without
going into details, here are some of the problems:

  * The API is not documented.  It is hard to know which functions are
    meant to be used by client code.  In fact, it is hard to know what
    constitutes client code, since the table code is in the hemlock
    internals package.

  * The documentation for the implementation is totally
    incomprehensible.  

  * The coding style looks old with structs instead of classes,
    old-style loop macros, buffers without fill pointers, etc. 

  * There is (I think) at least one bug that makes the library not
    work if given a string longer than 128 character. 

  * The use (admittedly thread-safe) of special variables to hold
    values to be communicated between certain macros and functions
    looks weird. 

As far as I can tell, this library is used at interaction speed, so it
would not have to be that fast, especially if, as now, maintainability
is a problem.  

A library like this would be useful in McCLIM.  I therefore decided to
rewrite it in a more modern style, less optimized but much shorter and
more idiomatic.  Currently, the library is around 600 lines of
non-comment code.  I think I can do it in 150-200 lines of code tops,
especially if I use the split-sequence function that is floating
around.  Also, I would prepare it for Unicode in Lisp implementations
where the character type is not Unicode, by making it work on
sequences of any type and not just characters, in this case,
presumably fixnums.

I was thinking of integrating this code into the McCLIM distribution.
It could be used for completion in McCLIM, but also (eventually) by
the CLIM-version of Portable Hemlock.

Anyway, this message is just to let you know that I am working on it,
and I expect to have some results in a few days.  It is a matter of a
few hours at most to write it, but I am on vacation, and my ADSL line
was just cut off for an upgrade to 2Mbits/s, so I cannot work
full-time on this right now.  Also, I have more things to do, like
Unicode for McCLIM, Gsharp, Flexichain, etc. 

-- 
Robert Strandh

---------------------------------------------------------------------
Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.
---------------------------------------------------------------------




More information about the phemlock-devel mailing list