Sunday, May 17, 2009

Deadwood snapshot update

OK, it's time to abstract the code a little more. I need to use the same kind of "dictionary" (as it's called in Python; it's called an "associative array" in AWK, a "hash" in Perl, and a "table" in LUA) elsewhere in the code, so I'm taking the currently very simplistic [O(N) instead of O(log N) (btree) or O(1) (hash)] code and putting it in its own file (DwDict.h and DwDict.c).

I'm abstracting the data, so when I want to make the code use a different structure (probably a hash so I can reuse a lot of stuff in DwHash.c), I can fairly easily change things.

Right now, DwMararc.c still duplicates the same code, so I need to take the functions that deal with dictionaries in DwMararc.c and have them call the appropriate functions in DwDict.c (and make header files and so on and so forth).

You know, one of these days, like soon, I need to learn C++ and its templates. I know C++ has some handy dictionary code in place so I don't have to deal with this stuff. C truly is portable assembly; it's small (32k binary for the non-recursive cache), it's fast, but it's a pain in the butt to code.

Deadwood will probably be my last old-fashioned C programming project. The next language I will use will probably be C++, and might possibly be Java. We'll see.

In the meantime, people can look at this snapshot at