August 17, 2006
Refer to "The future of lambda delegates" on ng.D ?

Apparently some changes here are scheduled for a post 1.0 release





Søren J. Løvborg wrote:
> Walter Bright wrote:
> 
>>Bug fixes.
> 
> 
> Excellent. I'm particularly glad to see bug 279 fixed so soon. Thanks!
> 
> I do note, however, that in the fix, you've created a distinction between two different kinds of inner classes, those that refer to local variables and those who don't.
> 
> Those who don't access local variables work as they always have (and thus, no old code is broken).
> 
> Those who do access local variables can only access them until the containing method returns, just as with inner functions, but (not too surprising when you know the internals) can _also_ only access members of the containing class until the containing method  returns, because (I suppose) access to the containing class now goes through the "this" local variable of the method, instead of directly through the context pointer as usual.
> 
> ===
> abstract class Inner { abstract void print(); }
> 
> class Outer
> {
>     int memberVar = 123;
> 
>     Inner inner;
> 
>     this()
>     {
>         int localVar = 42;
> 
>         inner = new class Inner
>         {
>             void print() { printf("%d %d\n", memberVar, localVar); }
>         };
>         inner.print();
>     }
> 
>     void print() { inner.print(); }
> }
> 
> void main()
> {
>     Outer o = new Outer(); // prints 42 123
>     o.print();             // prints two garbage numbers
> }
> ===
> 
> If the test-case above is modified to only access memberVar, everything works as expected.
> 
> Depending on how deliberate this is, this will need to be either documented or fixed (by having not one, but two content pointers in the inner classes that require it, perhaps).
> 
> In either case, I'm very happy with this release, so thanks again!
> 
> Søren J. Løvborg
> web@kwi.dk 
> 
> 


1 2 3
Next ›   Last »