poll for properties

Nick Sabalausky a at a.a
Tue Jul 28 16:33:04 PDT 2009


"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
news:op.uxstnfvpeav7ka at localhost.localdomain...
> Please respond to this poll before reading other responses.
>

Ok :)

> Assuming you have no idea what type Box is, what of the following options 
> looks most natural for xxx in order to test to see if b has an element in 
> it?
>
> a) if(b.empty)
> b) if(b.empty())
> c) if(b.clear)
> d) if(b.clear())

a) if(b.empty)

> What would you guess looks most natural for yyy in order to remove all 
> elements from b?
>
> a) b.empty;
> b) b.empty();
> c) b.clear;
> d) b.clear();

d) b.clear();

> Which of the following functions looks incorrect?

All of the above, but "a" looks best.

> Now knowing what the actual meaning of clear and empty are, indicate which 
> version(s) of the function in the previous question would surprise you if 
> it compiled.

"b" and "c", because "clear" and "empty" are both defined as functions that 
return bool. But regardless, I'd consider it a poorly designed API for a 
number of different reasons.

> Do you think the meaning of a symbol with parentheses suggests something 
> different than that same symbol without parentheses for the following 
> symbols:
>
> a) select
> b) rock
> c) keyboard
> d) elevate

Absolutely.





More information about the Digitalmars-d mailing list