On Wednesday, 14 May 2014 at 22:32:01 UTC, Jonathan M Davis via Digitalmars-d-learn wrote:
Yeah, much as Andrei would hate to hear it (enforce was his idea, and he quite likes the idiom), the fact that lazy is so inefficient makes it so that it's arguably bad practice to use it in high performance code. We really need to find a way to make it so that lazy is optimized properly so that we _can_ safely use enforce, but for now, it's not a good idea unless the code that
you're working on can afford the performance hit.

Honestly, in general, I'd avoid most anything which uses lazy (e.g. that's why
I'd use explict try-catch blocks rather than use
std.exception.assumeWontThrow - like enforce, it's a nice idea, but it's too
expensive at this point).

- Jonathan M Davis

On the topic of lazy, why *is* it so slow, exactly? I thought it was just shorthand for taking a function that evaluates the expression, and wrapping said expression in that function at the call site. That is, I thought that:

int doSomething(lazy int n)
{
    return n();
}

Was more or less equivalent to:

int doSomething(int function(int) n)
{
    return n();
}
  • Array!T and find are slow Damian Day via Digitalmars-d-learn
    • Re: Array!T and find are... David Nadlinger via Digitalmars-d-learn
      • Re: Array!T and find... Damian Day via Digitalmars-d-learn
        • Re: Array!T and ... David Nadlinger via Digitalmars-d-learn
          • Re: Array!T ... Kapps via Digitalmars-d-learn
            • Re: Arr... monarch_dodra via Digitalmars-d-learn
            • Re: Arr... Jonathan M Davis via Digitalmars-d-learn
            • Re: Arr... Meta via Digitalmars-d-learn
              • Re:... Kapps via Digitalmars-d-learn
                • ... Jonathan M Davis via Digitalmars-d-learn
                • ... monarch_dodra via Digitalmars-d-learn
                • ... Jonathan M Davis via Digitalmars-d-learn
                • ... monarch_dodra via Digitalmars-d-learn
                • ... Ary Borenszweig via Digitalmars-d-learn
                • ... Jonathan M Davis via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Jonathan M Davis via Digitalmars-d-learn
                • ... w0rp via Digitalmars-d-learn

Reply via email to