Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Who needs exceptions?

Name: Anonymous 2012-07-04 20:46


//in some class or namespace:
typedef unsigned int error_code;
const error_code out_of_mem = 0x01,
  niggers = 0x02,
  jews = 0x04;

error_code f()
{
  error_code ret = 0;
  //do some stuff...
  //suddenly niggers
  ret |= niggers;
  //but it's not a fatal error so we will continue execution
  //...
  if(some_pointer == nullptr)
  {
    ret |= out_of_mem;
    goto cleanup;
  }
  //and so on...
cleanup:
  delete some_pointer;
  //etc...

  return ret;
}

void implementation()
{
  error_code f = f();
  if( f & out_of_mem )
    //handle error
    printf("%s\n", "allocation failure");

  if( f & niggers )
    pool.close();
}


The main point of exceptions is to separate error detection from error handling. This accomplishes that. If you need the advanced features of exceptions, take a good look at your design and, more importantly, your life.

Name: Anonymous 2012-07-04 21:11

wow dude you have made a hatchet job of this. learn to write proper code. no goto's, no custom error codes unless your codebase is the size of my dick (which is huge)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List