From: Dan Sugalski Date: 2002-09-06T09:53:17+09:00 Subject: Re: Ruby aesthetics At 9:45 AM +0900 9/6/02, Yukihiro Matsumoto wrote: >Hi, > >In message "Re: Ruby aesthetics" > on 02/09/06, Christian Szegedy writes: > >|What I really dislike in Ruby, that the data members are seen >|by the child classes. This is a very serious issue, and a claer >|violation of object-orientation. >| >|I think Ruby would be a much better language if the instance >|variables would only live per class and not per hierarchy... > >It's in the ToDo list. Private instance variables will be something >like @_foo. But it's pretty hard to implement. If someone come up >with a good idea, I'm glad to hear. You can use a hierarchic storage system for this. Each class (or object, or whatever you want) has a pointer to its name table (or scratchpad, or private array, or hash, or...) and that name table has a pointer to a parent name table. When you do the lookup, the lookup routine can privately fail its way up the chain of name tables. It's a bit more expensive, since you have multiple tables to check, but it does work out OK, and there are caching tricks you can play to speed it up. -- Dan --------------------------------------"it's like this"------------------- Dan Sugalski even samurai dan@sidhe.org have teddy bears and even teddy bears get drunk