From: Austin McDonald Date: 2004-06-12T05:14:57+09:00 Subject: Re: Virtual instance-variable accessors I can see how it would be more efficient this way. Good work on CShadow, btw. Thanks! Austin Joel VanderWerf wrote: > Austin McDonald wrote: > >> When I access an private variable, using @var inside a method, is >> there any way to capture that using a C extension? Or am I forced to >> use rb_iv_set/get to keep the ruby instance variable up to date? I >> would like for @var to call a C function; can this be done? > > > AFAIK, there's no way to do this without hacking ruby. > >> I've looked at CShadow, and it seems like it requires you to use >> self.var, which I've already figured out how to do. > > > Yeah. If I knew a way to "hook" ivar access, CShadow would have used > it. But ruby probably is more efficient without the hooks since it > would always have to check for them, and allocate space for them. > > One alternative is to declare the accessors protected. > >