Empty field doesn't exist for arrays, right?

Jesse Phillips jessekphillips+D at gmail.com
Tue Mar 8 13:28:07 PST 2011


Andrej Mitrovic Wrote:

> On 3/8/11, Jesse Phillips <jessekphillips+D at gmail.com> wrote:
> > 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!"
> 
> But wouldn't this case be much more obvious with the property error
> message? Or maybe it wouldn't.. all I know is I got bitten by this
> error message a couple of times and it always got me that WTF look on
> my face.

I don't think so. If you didn't know empty was a library feature then you'd get the message, "empty is not a property of array." and be confused thinking that other code uses it. It would probably result in looking up other code which uses it then the properties available to arrays in the documentation and then a post to the NG confused on how other code gets away with it.

I don't really know, it just seems like someone is going to be lost no matter what it is.

> How common are typos in invoking methods versus typos in implementing
> methods like a UFCS function?

But if you know that empty is a function not a property, then the error makes much more sense. I think the confusion comes from not knowing it is a property or a function you are trying to call.


More information about the Digitalmars-d-learn mailing list