BigInt foreach loop
    Stefan Koch via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Aug  4 06:00:34 PDT 2017
    
    
  
On Friday, 4 August 2017 at 12:49:30 UTC, Q. Schroll wrote:
> One can do
>   BigInt n = returnsBigInt();
>   foreach (i; BigInt(0) .. n)
>   { .. }
> How is this implemented? The code for BigInt is very large and 
> I didn't find it.
> And is it more efficient than
>   for (BigInt i = 0; i < n; ++i)
>   { .. }
> as incrementing is a costly operation?
you can see what the code is lowerd to with -vcg-ast
The hand-written for is as effective as foreach usually.
    
    
More information about the Digitalmars-d-learn
mailing list