[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rb_cv_set defines class var but doesn't?

Tim Hunter

3/27/2008 11:24:00 PM

I'm using rb_cv_set in a C extension to set the value of a class
variable. Via gdb I can see that rb_cv_set successfully creates the
variable. The rb_cvar_defined function returns Qtrue and a subsequent
call to rb_cv_get returns the correct value. From the C side, everything
is copacetic.

From Ruby, however, things are squirrely. Using class_eval I can see
the variable:

MyClass.class_eval { p class_variables }

shows ["@@_tmpnam_"] as expected. However,

MyClass.class_eval { x = @@_tmpnam_ }

raises NameError: "uninitialized class variable @@_tmpnam_ in MyClass".

MyClass.class_eval { p defined? @@_tmpnam_ }

shows "nil".

I'm running 1.8.6 patchlevel 114 on Kubuntu Gutsy.

This works as expected with Ruby 1.9.0-1.

Is this just a bug in 1.8.6? Is there another way I can inspect the
value of @@_tmpnam_ in 1.8.6?

--
RMagick: http://rmagick.ruby...
RMagick 2: http://rmagick.ruby...rmagick2.html