October 9, 2005

It is always interesting to see how the worst hack imaginable can sometimes actually get the job done remarkably well. Last night, in a 4 hour PHP coding stint, I wrote a small script to read in a schedule text file, parse it, and display the items, timeframes, people working on tasks, notes, and percent completed to display it on the robotics website. It’s gotta be the worst PHP you’ve ever seen, but looking at the webpage, you wouldn’t guess that.

Or take my C++ plugins project. In C++, you can’t have a function pointer that takes variable arguments. So unless you resort to assembly language, you have to have one function pointer for each number of parameters. One for a function with no parameters, another for a function with one parameter, and so forth. So if you want to support up to 20 parameters, you have to have 20 different function pointers, the only difference being the number of parameters they take. But to further complicate things, there are different calling conventions. So you have 20 for the C calling convention and then another 20 for the standard calling convention. It’s got to be some of the hackiest C++ code I’ve written, but it’s the only way and it accomplishes the goals so I can’t complain too much.

Posted in: old Filed under: