On Wednesday 27 June 2007 02:05, Erik Johansson wrote:
> Except for the ones I've commeted on below, I fully agree.

I will update the Wiki page on my lunch break or after work then :)

> I don't think we should ban varargs. For e.g. log functions it's
> really useful. But we should try very hard to avoid it.

Useful, but not very C++ like. varargs removes any type checking of parameters 
to the functions, which makes us rely on printf's formatting that is prone to 
errors and unsafe by nature. I think using boost::format would be much better 
than C's varargs and the printf family.

Take a look here for more details, the syntax is a bit different, but it 
provides type checking and is much safer: 
http://www.boost.org/libs/format/index.html

> The same here, for some problems, it's just the best solution to use
> snprintf and friends. But as above, try to avoid them but if needed
> use the secure variants (that take a size argument).

Yes, the secure variants are better. But why not just use C++'s methods? Using 
boost makes it pretty easy and like I said above, will give us proper usage 
of C++.

> I agree that we should use exceptions, but we have to be careful when
> throwing across DSO:s (http://gcc.gnu.org/wiki/Visibility).

Plugins shouldn't really be throwing beyond themselves. We should probably 
specify that in the Plugin documention.

> Where it makes sense, I'm all for it.

I'm pretty sure it is much easier to find examples of when it makes sense than 
when it doesn't make sense. Using the STL's algorithms techniques makes us 
code in a way that keeps one function to one task. For example...

void ICQ::Logoff()
{
  // Mark all users as offline
  for_each(users.... changeStatus(user, offline));

 // other work
}

is much better than...

void ICQ::Logoff()
{
  // Mark all users as offline
  for (iter = users.begin(); ... ++iter)
  {
      user->setStatus(offline);
      // other offline work
  }
}

and lets C++ create an optimal loop where we don't have to worry about the 
parameters as much..

  for (iter = users.begin(); ... ++iter)
   changeStatus(*iter, offline);

Jon

-- 
________________________________________________________
Jon Keating                ICQ: 16325723
[EMAIL PROTECTED]               MSN: [EMAIL PROTECTED]
http://www.licq.org        GPG: 2290A71F
http://www.thejon.org      HOME: Minamiashigara, Japan

Reply via email to