From: Paul Brannan Date: 2003-02-04T07:24:36+09:00 Subject: Re: ruby-dev summary 19437-19455 On Tue, Feb 04, 2003 at 03:35:50AM +0900, Yukihiro Matsumoto wrote: > In message "Re: ruby-dev summary 19437-19455" > on 03/02/04, ahoward writes: > > |why not a more general > | > | static > | > |which heap allocates/evaluates statement once in the local scope - ananlogous > |to C's static. > > C's static is global that extent is limited to enclosing block (or file). > I don't think it's what we want. In C (and C99 and C++), the static keyword has different meanings, depending on the context: // tentative declaration of x; x will have internal linkage (no symbol // is generated for x, thus x is not visible outside this translation // unit) static int x; // definition of x; it will have value 42 when initialized static int x = 42; void foo() { // x is a local variable but has static storage duration (that is, // its lifetime is as long as the program, and it is initialized // when the program starts). It is *not* global; this is a // function-local variable that shadows a translation-unit-local // variable. static int x = 10; } // C++: example of a static member function; indicates that the function // has no implicit this argument (and can therefore be called without an // object); this is analgous to a class method in Ruby. class Foo { static void foo(); } void Foo::foo() { // C++: example of a variable with static storage duration; its // lifetime begins when the below statement is executed. (**) static Bar b; } // C99: the argument corresponding to a in any call to f must be a // non-null pointer to the first of at least three arrays of 5 // doubles. void f(double a[restrict static 3][5]); In short, the static keyword in C is very surprising. If we were to add it to Ruby, we must be certain that there is no ambiguity and that there is no surprise involved, as that would violate POLS. Of course, if Ruby had a static keyword and it did not have a few surprises up its sleeve, I would be very surpised, and that too could potentially violate POLS. :) FWIW, I think what the author intended was the usage of static that I have marked with (**). Paul