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

static in C

Name: Anonymous 2010-10-16 17:23

I can see why you would want static variables in functions but what's the point of static globals?

Name: Anonymous 2010-10-16 19:41

>>7
#include <stdio.h>
struct x { long x; };
int main(int argc, char *argv[])
(
    struct x x;
    x.x = strtol(argv[i]);
    if (x.x) goto x;
    return 0;
x:
    return 1;
}


Note that none of the "x" collide because they are in different namespaces.  There's a namespace for tags (struct x), one for each structure for fields (forgot to mention it), one for labels, and one for objects (the "x" variable).  It's a matter of nitpicking, but according to the standard there is one namespace for each structure's fields, but only one namespace for all labels... but labels won't be in scope outside a function.

Common Lisp also has different namespaces, most notable it has a separate namespaces for functions and data:

(defun f (car) (car car))

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