On Fri, 28 Jan 2005, Trans wrote: >> I have run into this problem myself, and have not seen a good >> solutoin to it. I have a suspicion that it probably means the >> separation of the two classes, in this case Parser and Token, >> is an incorrect model, because they both need access to each >> other. > > Hmm... I'm not sure how that can be outside of through OOP out the > window. If I combine the Token and the Parser into a single thing then > that will really be the only thing there is ;-) Yes. That's why I only consider it a suspicion, and why I say I haven't seen a good answer to it yet. Thinking out loud: What if when instance vars were created they got a container() method which returned the containing class? Or maybe have a contains keyword like attr (and friends) that sets this up for you. It feels like unwanted coupling, though. In thinking Forth (http://thinking-forth.sourceforge.net/) Leo Brodie says that such a case should have the commonality extracted into an interface, each side talking to the interface in the way that is most suitable. Then outsiders can get at the interface. [This is paraphrased from memory. Oh, just a minute...] "Tip Both data structures and the commands involved in the communication of data between modules should be localized in an interface component." This means you can change the interface easily later. This begins to look like "model, view, controller" to me. > > I'll think on it some more though. > I take it you've looked at parser.rb then? Yes, it looks good but I've not got far with it yet. > > T. > Hugh