On 8/9/17 5:40 PM, H. S. Teoh via Digitalmars-d-learn wrote:
On Wed, Aug 09, 2017 at 09:34:26PM +0000, Q. Schroll via Digitalmars-d-learn
On Friday, 4 August 2017 at 16:40:08 UTC, Stefan Koch wrote:
foreach(x;A .. B)
it's lowerd to
auto limit = B;
auto key = A;
for(auto x = key;key < limit;++key)
// use x
That's enough to know that the foreach loop does not reuse the space
for the iteration variable. That was what I cared about.
Note that using BigInt as iteration variable will probably cause a
BigInt allocation per iteration, because operations on BigInt in general
will allocate a new BigInt result. So `++key` will probably create a new
instance of BigInt each time it's executed.
Right, but this is not a limitation of the API, just the implementation.
It could be improved.