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

I am a C Programmer

Name: Anonymous 2012-01-27 23:08

Yes. I'm a C programmer. So? I don't see a problem. I embraced my UNIX soul long ago and I am happy together with my compiler (who is a cute layered front/backend design!). We have a fucking lot of functions in and outside of the kernel and I am pretty compact and resource conserving.

But thanks anyway asshole. Go and beat off to your stupid garbage collection shit while I #INCLUDE <stdio.h> with my preprocessor.

Name: Anonymous 2012-01-27 23:45

>>5
If you want OOP in C (inheritance, constructors, deconstructors, etc.) do something like this:



typedef struct object object;

enum {
  T_NUM,
  T_STR
};

struct object {
  int type;
  union {
    double num;
    char *str;
  } val;
};

object *new_obj(int type) {
  object *obj;

  obj = malloc(sizeof(*obj));
  obj->type = type;
  return obj;
}

object *new_num(double num) {
  object *obj;

  obj = new_obj(T_NUM);
  obj->val.num = 0;
  return obj;
}

object *new_str(char *str) {
  object *obj;

  obj = new_obj(T_STR);
  obj->val.str = strdup(str);
  return obj;
}

void delete(object *obj) {
  if (obj->type == T_STR)
    free(obj->val.str);
  free(obj);
}

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