BitArray new design
    Era Scarecrow 
    rtcvb32 at yahoo.com
       
    Thu Jan 10 13:50:16 PST 2013
    
    
  
On Thursday, 10 January 2013 at 21:37:22 UTC, Dmitry Olshansky 
wrote:
> It's only for classes AFAIK. Inner structs of structs (LOL) 
> don't have it.
  Why not? I don't see a reason why not personally. Umm maybe I 
do... the outer struct becomes referenced to S2, so...
  struct S {
    int x;
    struct S2 {
      int getX(){return x;}
    }
    S2 s2;
  }
  S.S2 func(){
    S s;
    return s.s2;
  }
  auto x = func();
  writeln(x.getX()); //prints garbage? Or access violation.
  If func had used new on s, then it would have worked... Yeah I 
see the problem now. The only way that would work is if S2 is 
never allowed to be passed outside a function, and on copying the 
new hidden pointer is updated to the new location. That makes 
sense. Maybe something walter will consider.
> Sounds good and seductively simple.
  Yeah I hope so. We'll see, that's the design I'll go for. I'll 
let you know how it goes; Should at least simplify the code and 
remove the need for bitfields.
    
    
More information about the Digitalmars-d-learn
mailing list