class design question (inner classes)

Bruno Medeiros brunodomedeiros+spam at com.gmail
Wed Sep 12 12:38:39 PDT 2007


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() {
>     A a = new A();
>     [... initialize many a.Inner objects here ...]
> }
> 
> Once that "a" is initialized, te 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?

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.

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list