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

Stylistic choices

Name: Anonymous 2011-12-13 3:18

I tend to prefer to use namespaces filled with constants, rather than using enums in most cases. For example using

namespace Element {
const uint8_t No_Element = 0;
const uint8_t Air = 1;
const uint8_t Water = 2;
const uint8_t Earth = 3;
const uint8_t Fire = 4;
};


instead of


enum Element {
No_Element, Air, Water, Earth, Fire
};


Is this bad practice?

Name: Anonymous 2011-12-13 4:39

>>10
#define ... no abstraction
tell that to the people who define header only data structures
int main (int argc, char ** argv) {
  int i;
  struct list l;

  do { struct list * __s = (&l); __s->h = ((void *)0); __s->t = ((void *)0); __s->s = 0; } while (0);

  while (--argc)
    do { struct list * __s = (&l); list_type __e = (atoi(*++argv)); struct list_node * __n; __n = list_node_alloc(__e); if (__n == ((void *)0)) break; if (__s->s == 0) { __s->h = __s->t = __n; } else { __n->n = __s->h; __s->h->p = __n; __s->h = __n; } __s->s += 1; } while (0);

  do { struct list_node * __n = (&l)->h; while (__n != ((void *)0)) { int n = __n->e; {
    printf("%d!\n", n);
  } __n = __n->n; } } while (0);

  do { struct list * __s = (&l); struct list_node * __n = __s->h; struct list_node * __t; while (__n != ((void *)0)) { __t = __n; __n = __n->n; do { struct list_node * __s = (__t); ; free(__s); } while (0); } do { struct list * __s = (__s); __s->h = ((void *)0); __s->t = ((void *)0); __s->s = 0; } while (0); } while (0);

  return 0;
}

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