Name: Anonymous 2011-10-24 21:45
Let's have a thread for the C programming language. It's an excellent language.
int foo()
{
// Create two 1000x1000 unit matrices:
Matrix a, b, c;
if(!Matrix_init(&a, 1000, 1000)) goto exit_foo;
if(!Matrix_init(&b, 1000, 1000)) goto exit_foo;
// Do something with a and b here, for example:
if(!Matrix_init_with_matrix(&c, &a)) goto exit_foo;
if(!Matrix_multiply_by_constant(&c, 2)) goto exit_foo;
if(!Matrix_add(&c, &b)) goto exit_foo;
...
exit_foo:
Matrix_destroy(&a);
Matrix_destroy(&b);
Matrix_destroy(&c);
return some_value;
}
int foo()
{
// Create two 1000x1000 unit matrices:
Matrix a, b, c;
if(Matrix_init(&a, 1000, 1000))
{
if(Matrix_init(&b, 1000, 1000))
{
// Do something with a and b here, for example:
if(Matrix_init_with_matrix(&c, &a))
{
if(Matrix_multiply_by_constant(&c, 2))
{
if(Matrix_add(&c, &b))
{
...
}
}
}
}
}
Matrix_destroy(&a);
Matrix_destroy(&b);
Matrix_destroy(&c);
return some_value;
}