On 8/9/17 9:08 PM, Steven Schveighoffer wrote:
Right, but this is not a limitation of the API, just the implementation.
It could be improved.
https://issues.dlang.org/show_bug.cgi?id=17736
Based on H.S. Teoh's comment in the bug report, this actually is invalid.
That's a tough requirement.
On 8/9/17 5:40 PM, H. S. Teoh via Digitalmars-d-learn wrote:
On Wed, Aug 09, 2017 at 09:34:26PM +, Q. Schroll via Digitalmars-d-learn
wrote:
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;ke
On Wed, Aug 09, 2017 at 09:34:26PM +, Q. Schroll via Digitalmars-d-learn
wrote:
> 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
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 c
On Friday, 4 August 2017 at 13:09:55 UTC, Steven Schveighoffer
wrote:
Any foreach range statement like this:
foreach(var; A .. B)
is treated as if you wrote:
for(auto var = A; var < B; ++var)
So it's pretty much exactly like what you wrote, just the
initializer is different but the result
On 8/4/17 8:49 AM, 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)
{ .. }
Any foreach range
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
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?