Eglin
11-12-2003, 03:21 AM
I'm just getting to know your codebase, and I find the lack of coding standards to be a bit overwhelming. I guess this is just symptomatic of having a lot of cooks in one kitchen. It feels like the early Java API, where you could clearly tell which routines were written by which authors because the interfaces were so wildly different! hehe... I noticed that at least one major developer is intimately familiar w/ STL (the single biggest source of my rejuvenated love for c++), while others are ingrained in basic c.
Sorry if my post seems inflammatory... At any rate, I thought I'd mention that I found the i/o functions (and the makeanylengthstring) to be dangerous. Instead of c++ style i/o where the object to be output is asked to serialize itself into a stream or the really new style i/o where you use output iterators to walk structures, most i/o uses the va_args stuff that died back with the stdio stuff a decade ago. The problem with the va_args stuff is that it totally disables c's very refined type-checking. As an example of why this could be problematic, consider the following snippet:
std::string msg = "teststring";
c->Message(0, "test: %s", msg);
This, of course, isn't correct code. However, it is a very easy mistake to make. By bypassing the type-checking of parameter passing, we have also taken away the compiler's ability to warn us of this error. So, by using msg (like we're used to w/ most library i/o routines) instead of msg.c_str(), we've introduced a runtime error that could easily bring down the entire system. Also a very insidious error to track down.
Not really sure what I hoped to accomplish by posting this (maybe just a gotcha! warning). I certainly don't mean to talk trash about your codebase (or I wouldn
Sorry if my post seems inflammatory... At any rate, I thought I'd mention that I found the i/o functions (and the makeanylengthstring) to be dangerous. Instead of c++ style i/o where the object to be output is asked to serialize itself into a stream or the really new style i/o where you use output iterators to walk structures, most i/o uses the va_args stuff that died back with the stdio stuff a decade ago. The problem with the va_args stuff is that it totally disables c's very refined type-checking. As an example of why this could be problematic, consider the following snippet:
std::string msg = "teststring";
c->Message(0, "test: %s", msg);
This, of course, isn't correct code. However, it is a very easy mistake to make. By bypassing the type-checking of parameter passing, we have also taken away the compiler's ability to warn us of this error. So, by using msg (like we're used to w/ most library i/o routines) instead of msg.c_str(), we've introduced a runtime error that could easily bring down the entire system. Also a very insidious error to track down.
Not really sure what I hoped to accomplish by posting this (maybe just a gotcha! warning). I certainly don't mean to talk trash about your codebase (or I wouldn