Can we get rid of opApply?

Steven Schveighoffer schveiguy at yahoo.com
Mon Jan 19 12:22:21 PST 2009


"Steven Schveighoffer" wrote
> // foo translates to:
>
> foo(R r)
> {
>   for(auto __r = r; !__r.empty(); __r.next())
>   {
>       auto x = __r.head();
>   }
>   for(auto __r = r; !__r.empty(); __r.next())
>   {
>       int i, x; // compiler figures out from signature of head()
>       __r.head(&i, &x);
>   }
>   for(auto __r = r; !__r.empty(); __r.next())
>   {
>      int i; // compiler figures out from signature of head()
>      int *__x; // only here for explanation, compiler would optimize this 
> extra variable out.

>      __r.head(&i, &x);

Oops, that should have been:

      __r.head(&i, &__x);

>      ref int x = *__x; // ditto
>   }
> } 





More information about the Digitalmars-d mailing list