<br><br><div class="gmail_quote">On Fri, Apr 22, 2011 at 10:39 AM, Steve Schveighoffer <span dir="ltr"><<a href="mailto:schveiguy@yahoo.com">schveiguy@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div style="color:#000;background-color:#fff;font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>Bug reports. People having stupid arguments just like this one on why you should change how the code works to fit their style ;)</span></div>
<div><br><span></span></div><div><span>Essentially, ambiguously named functions in the context of "I can call this as a property or a function" lead to people getting surprising behavior and then complaining about the surprise, when I can do nothing about it.</span></div>
<div><br></div><div>I've actually had this happen. I had to change function names in Tango in order to avoid people complaining. The example was, I had a bunch of generator functions in TimeSpan, like</div><div><br>
</div><div>// create a time spand that represents the given number of seconds<br></div><div>static TimeSpan seconds(int s)<br></div><div><br></div><div>which would be used like
this:</div><div><br></div><div>auto s = TimeSpan.seconds(5);</div><div><br></div><div>But it could also be used as a property. So this compiled and constructed a temporary time span and throw it away:</div><div><br></div>
<div>TimeSpan s;</div><div><br></div><div>s.seconds = 5;</div><div><br></div><div>So we had to change seconds to fromSeconds. It still allows code like this:</div><div><br></div><div>s.fromSeconds = 5;</div><div><br></div>
<div>but instead of being disallowed, it just looks horrible, hopefully cluing the reader to go examine the documentation for TimeSpan. That's the best we can do. I have no power to enforce the usage.<br></div><div>
<br></div><span></span><div><span>-Steve<br></span></div><br></div></div></blockquote><div><br>Nor should you. People who are confused should RTFM. BTW, what if you, as a library designer, <b>want</b> to express the notion that something can be called both ways? <br>
</div></div>