Version 3 of Quality of source code

Updated 2003-03-20 19:11:05

Arjen Markus (17 december 2002) I want to make a statement about the quality of the source code of the Tcl core. I do not mean to flatter the original developers (well, not too much anyway), but I am impressed! Let me explain why:

Last week I discussed the possibility of adding a new operator (exponentiation) to the expr command. I was fooling around a bit with higher-degree polynomials and other such maths stuff and I felt that such an operator would help a lot. Donal Fellows, Jeff Hobbs and Reinhard Max were engaged in this discussion, as well as several others. Reinhard was enthusiastic about the idea, clarified his thoughts about the difference between the existing pow() function and the possible implementation (return floats or integers), Jeff suggested that I try to make a reference implementation first and Donal indicated where to put the necessary changes.

Adding an operator with its proper semantics, precedence and effects is not a trivial matter. I took several print-outs with me, studied them, and decided that it was quite doable.

Then last night, I sat down, added a subroutine to the expression parser to take care of the string ** (my new operator), updated a few tables, added the proper case to the byte code engine (three cases in fact) and of course the subroutines that were necessary for the evaluation if the operands are integer.

Compiling, linking and testing this new implementation revealed various initial quirks and problems. All in all, I had to change about four source files. Source files I had never studied before!

I succeeded in making a reference implementation - in about two hours. Another half hour was required for writing up the TIP, and then I was finished, feeling proud to have achieved this. And feeling proud to be able to work with such software.

Tips for writing quality software