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

Languages with GOTO

Name: suomynonA 2007-07-17 12:49 ID:sJhm9IHJ

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: Anonymous 2007-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);

  failure:
  return NULL;
}

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