Ref / NotNull struct

Namespace rswhite4 at googlemail.com
Sun May 6 08:13:01 PDT 2012


On Sunday, 6 May 2012 at 14:04:30 UTC, Simen Kjaeraas wrote:
>
>
>> I would be glad for criticism and suggestions and maybe a 
>> solution/workaround for the infinite loop bug, if it's the 
>> case, that it's really a bug.
>
> First thought (after just copying the code and compiling it, 
> not reading the
> post :p), was 'where are the unittest blocks?' Then I saw you 
> had a separate
> module.
>
> As for the infinite loop bug, consider this:
>
> class A {
>     B b;
>     alias b this;
> }
>
> class B {
>     A a;
>     alias a this;
> }
>
> void main( ) {
>     A a = 3;
> }
>
> This fails with the exact same message.
>
> The compiler goes 'Eh, no int in A. But ooh, there's an alias 
> this here!'
> 'Eh, no int in B. But ooh, there's an alias this here!'
> Repeat as necessary.
>
> Filed as 8053:
> http://d.puremagic.com/issues/show_bug.cgi?id=8053

Ah, I see. Thanks for this. I'm glad when dmd 2.060 comes and fix
this.
That is really a little bit annoying. I hate the ".acces"
notation to access the object which is holding by Ref.
But I have a workaround for the problem:
use mixin Proxy!(this._obj); and it works. Now the only problem
is, that Ref!(Foo) cannot be downcast to Foo, but you have now
full object access wihtout the ".access" notation. Great step
forward i think. :)
And as far as i used it, i needn't the conversion from Ref!Foo to
Foo.
Here the changed Code with test calls below:
http://codepad.org/lfxe5plJ

I must excuse me at this point again for my bad english.



More information about the Digitalmars-d-learn mailing list