Empty field doesn't exist for arrays, right?

Jesse Phillips jessekphillips+D at gmail.com
Tue Mar 8 10:58:38 PST 2011


Andrej Mitrovic Wrote:

> On 3/8/11, bearophile <bearophileHUGS at lycos.com> wrote:
> > empty is not an array method, it's a free function that is used with a
> > funny syntax.
> 
> Yes but the compiler doesn't know that until std.array is imported. A
> better error message is that empty isn't a property of that array.
> It's much easier to reason about this way.

What if you are trying to create a method which will act as a property for the array? If you get it wrong you would get the error that an array doesn't have the property and scream, "I know that is why I'm building a function for it. Why won't it find my function stead of looking at what array provides!"

Also doesn't TDPL introduce Ranges by implementing them for arrays and then tell you that you don't have to do this every time because it is an the standard labrary std.array?


More information about the Digitalmars-d-learn mailing list