Is this reasonable?

Steve Teale steve.teale at britseyeview.com
Fri Dec 6 09:14:52 PST 2013


On Thursday, 5 December 2013 at 17:15:39 UTC, 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);
> }
>
Oh my, what a hornet's nest!

I'd settle for an error that said that it's not permissible to 
compare a negative integer with a size_t. But almost any way you 
go is ugly.

Thank you all. I feel less like a beginner now ;=)


More information about the Digitalmars-d-learn mailing list