poll for properties
Adam D. Ruppe
destructionator at gmail.com
Tue Jul 28 15:48:57 PDT 2009
On Tue, Jul 28, 2009 at 06:19:53PM -0400, Steven Schveighoffer wrote:
> else
> b.yyy;
> }
>
> 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())
Both of those look equally fine. My top preference would probably be:
e) if(b.isEmpty)
though.
> c) b.clear;
This one. You are just ordering it to be cleared out.
> Which of the following functions looks incorrect?
> void c(Box box)
> {
> if(box.clear)
> box.fill(5);
> else
> box.empty;
> }
This looks weirdest, since I'm assuming clear clears it out.
> if(box.clear())
> box.fill(5);
> else
> box.empty();
> }
Not in love with that either, but it isn't as bad.
> 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.
None of them. Maybe it is just because I've been using D as my main language
for long enough already that I don't see the difference between
x;
and x();
(After all, "x;" is just stupid to write if it is a variable or property, since
it doesn't do anything, so logically, it must be a function.)
> Do you think the meaning of a symbol with parentheses suggests something
> different than that same symbol without parentheses for the following
> symbols:
None.
--
Adam D. Ruppe
http://arsdnet.net
More information about the Digitalmars-d
mailing list