Scope storage class [Was: DMD 1.037 and 2.020 releases]
Jarrett Billingsley
jarrett.billingsley at gmail.com
Wed Nov 26 06:18:32 PST 2008
On Wed, Nov 26, 2008 at 7:34 AM, bearophile <bearophileHUGS at lycos.com> wrote:
> This is the code I have used for DMD 2.021. I was not sure how to use the scope, so if you have improvements please tell me:
>
> import std.c.stdio: printf;
>
> int a(scope int k, lazy int x1, lazy int x2, lazy int x3, lazy int x4, lazy int x5) {
> scope int delegate() b;
> b = {
> k -= 1;
> return a(k, b(), x1, x2, x3, x4);
> };
> return k <= 0 ? x4 + x5 : b();
> }
>
> The code was too much slow in D2, so I have stopped it. Do you know if the D2 code can be improved to have performance similar to D1 ones?
Can you try declaring b as a nested function instead of as a delegate
literal and see if that helps? (why are you declaring it the way you
are, anyway?
More information about the Digitalmars-d-announce
mailing list