From: George Ogata Date: 2007-02-14T11:17:29+09:00 Subject: Re: Question about rb_cvar_set On 2/14/07, Daniel Berger wrote: > Hi, > > Ruby 1.8.5 p12 > > It looks like there was a prototype change in rb_cvar_set() at some > point in the 1.8.x branch. It now takes a 4th parameter (an int). What > is the 4th parameter supposed to be? Hi Dan, If you poke your nose into the rb_cvar_set() function, you'll see it's just a warning enabler flag. Specifically, if this argument is nonzero, then in verbose mode (-v, -w) you'll get a warning if you modify a class variable from a subclass. As in: $ ruby -w -e 'class B; @@x = 1; end; class D < B; @@x = 5; end' -e:1: warning: already initialized class variable @@x The flag appears to be used to distinguish between cases such as: class B @@x = 1 end class D < B @@x = 2 # warning def f @@x = 3 # no warning end def self.f @@x = 4 # no warning end end Here, although the last 3 assignments to @@x all modify B's @@x, the ones inside a def are considered "assignment-style", whereas the "@@x = 2" is "declaration-style". Only the latter generates a warning. Regards, George.