From: ahoward Date: 2003-02-04T06:15:01+09:00 Subject: Re: ruby-dev summary 19437-19455 On Tue, 4 Feb 2003, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: ruby-dev summary 19437-19455" > on 03/02/04, ahoward writes: > > |> C's static is global that extent is limited to enclosing block (or file). > |> I don't think it's what we want. > > | static int count = 0; // <-- THIS STATIC > > I know. It's still global with constant initializer. i'm not exactly sure how? my understanding is from the K&R book. if what you are saying is true, i'm not sure exactly how this works : ~/eg/c > cat static.c #include #include void foo (void) { static int count = 0; printf ("%s called %d times\n", __FUNCTION__, count++); } void bar (void) { static int count = 0; printf ("%s called %d times\n", __FUNCTION__, count++); } ~/eg/c > cat main.c extern void foo (void); extern void bar (void); int main (argc, argv, env) int argc; char **argv; char **env; { int i; for (i = 0; i < 4; i++) { foo (); bar (); } return 0; } ~/eg/c > gcc main.c static.c && a.out foo called 0 times bar called 0 times foo called 1 times bar called 1 times foo called 2 times bar called 2 times foo called 3 times bar called 3 times this _looks_ like the two counts are made 'private' to foo and bar, and also that the scope is not global, although i realize that allocation in the data segment might be what you meant by 'global'. i was referring to their scopes, which certainly seem not to be global. i have a feeling you will insert a reason that i am wrong, here -> in any case, a ruby 'static' could be similar in meaning if not in implimentation. perhaps this is more difficult than i realize to impl. in any case it seems like it would be usefull to have this _ability_ if not the syntax (no one ever likes my syntax ideas ;-) ). -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================