digitalmars.D - Re: class design question (inner classes)
- coxalan <coxalan web.de> Sep 15 2007
Bruno Medeiros Wrote:coxalan wrote:Regan Heath Wrote:[...] Ok. I think I have reached the limit of my usefulness here :) Someone else is bound to have some ideas.
It was my fear that I put too much technical mathematics stuff into my posting. I already put this question (in C++ form) into a mathematical internet forum, but then the OOP-design part of the discussion got stuck at a very basic level... :-) Now I rethought my question and how I can put it on a more abstract level to get out the math part. I guess my problem comes down to this point: class Outer { class Inner { [...] } [...] } main() { Outer a = new Outer(); [... initialize many a.Inner objects here ...] } Once that "a" is initialized, the reference "a" stays constant all the time. So all further references/pointers to "a" are redundant. Especially, the references to "a" stored in "a.Inner" inner objects are redundant. So if there was a way to tell the compiler that the reference "a" will never change, the compiler could do the optimization and skip all these inner-class-references. Now the question is: Is there currently a way to achieve a satisfying, equivalent result? If not: Should I make this a feature request? coxalan
I assume correctly that A == Outer in that example above?
Yes, sorry for that. Above I corrected that line.Some questions: is the total number of instances of Outer constant and known at compile time? If not, I think it's impossible to do what you want.
Yes, the number is known at compile time. I guess I will start a new thread now that I understand my problem much clearer. coxalan
Sep 15 2007