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 19:53 ID:8wGLwsNB

int alloc_some_things() {
  T* foo;
  void* member;
  void* another;
  foo = malloc(sizeof(*foo));
  member = malloc(sizeof(*foo->member));
  another = malloc(sizeof(*foo->another);
  if(foo && member && another)
  {
     foo->member = member;
     foo->another = another;
  }
  else
  {
     free(foo); // free is ok on NULL
     free(member); // free is ok on NULL
     free(another); // free is ok on NULL
  }
  return NULL;
}

or, if you like some wild macro action:

#define RETURNFREE(val) freevec(autofree); return val

int alloc_some_things() {
  T* foo;
  void* member;
  void* another;
  void* autofree[] = {foo, member, another};
  foo = malloc(sizeof(*foo));
  member = malloc(sizeof(*foo->member));
  another = malloc(sizeof(*foo->another);
  if(BIG NESTED STUFF)
  {
........ ok ? then return
  }
  else
....
  {
    RETURNFREE
  }
  another big nesst.....

   RETURNFREE! AGAIN YOU DONT HAVE TO REWRITE THE CODE
  return NULL;
}

NOTE: I don't guarantee compilation on these code examples.
NOTE2: you can do this better with nested procedures, which the gnu extensions to C allow.

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