Quoting Vincent Fourmond <vincent.fourmond / 9online.fr>:

> [I posted that yesterday lunch time, and it didn't get on the archive
> yet, so I'm posting that again.]
>
>  Hello !
>
>> That would work if the passed in object should be shared among all
>> instances of my class, but that's not the case since it's a
>> callback object that's supplied for a particular instance of my class.
>> Correct me if I'm wrong but the variable is only global in my C
>> code since I haven't made it visible to the Ruby environment with a
>> rb_gv_set(const char *name, VALUE value)?
>
>   Ooops... Unless I completely didn't get you right, you're going right
> into troubles. There will always be one instance of your C variable. So
> if you have several instances of your class, then everytime you use one,
> you will actually use the reference that you stored in the last instance
> created... it will all go wrong. I just can't understand why your 'self'
> will be gone out of scope. Do you destroy quickly the instances of your
> class ? But then, how do you expect to have a per-instance storage if
> you destroy the instances ?
>
>   Cheers !
>
> 	Vince
>
>
>

Hi Vince!

Of course, you are totally right!

The issue with self not being available was that I was calling  
yyparse() and hadn't configured bison so that yyparse was given any  
parameters, hence self wasn't available in the parser code. I didn't  
destroy it just couldn't reach it. Now I have taken a different  
aproach. yyparse is called with a parameter and instead of passing the  
callback instance as a parameter to initialize I have made it a  
class/module method instead, since the only task for my extension is  
to delegate the parsing routine.

Thanks again, though, for opening my eyes. There's been a long time  
since I wrote some C code and I didn't think about this.

/Christer