On 12/5/13 2:15 PM, Steve Teale wrote:
Here I feel like a beginner, but it seems very unfriendly:

import std.stdio;

struct ABC
{
    double a;
    int b;
    bool c;
}

ABC[20] aabc;

void foo(int n)
{
    writefln("n: %d, aabc.length: %d", n, aabc.length);
    if (n < aabc.length)
       writeln("A");
    else
       writeln("B");
}

void main(string[] args)
{
    int n = -1;
    foo(n);
}

This comes back with "B".

If I change the test to (n < cast(int) aabc.length), then all is well.

Is this unavoidable, or could the compiler safely make the conversion
implicitly?

Cough, cough, make array length be an int.

Do you really need arrays that big? :-S

(I'm talking to Mr. D Compiler here)

Reply via email to