Is there a modern programming language which has GOTO function in it? I know basic from a millenia ago and recently learned java, and well I hated OOP, but I could live with it if I had goto.
Name:
Anonymous2007-07-19 14:39 ID:QBsD/4JS
goto is good for freeing things up in C on error.
int alloc_some_things()
{
T *foo = malloc(sizeof(*foo));
if (foo != NULL)
{
foo->member = malloc(sizeof(*foo->member));
if (foo->member != NULL)
{
foo->another = malloc(sizeof(*foo->another));
if (foo->another != NULL)
{
return foo;
} else goto free_member;
} else goto free_foo;
} else goto failure;
free_member: free(foo->member);
free_foo: free(foo);