<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>The problem with RTFM is, they have a point.  s.seconds = 5 looks like it should work.  So that response looks like you don't care about usage.  D isn't a dynamic language.<br></span></div><div><br><span></span></div><div><span>If you *want* to express that a function can be called both ways, then we have to look into overloading properties and non-properties of the same name with the same arguments, or using an annotation.  But that's a separate enhancement.  We'd have to look at the merits of that separately, and I personally feel the ability to do that is not worth the trouble -- you can just as easily rename the function version, and it actually ends up reading clearer.  Yes, it's not always DRY, but DRY is never fully achievable, and is secondary to usage semantics
 IMO.<br></span></div><div><br></div><div>-Steve<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Arial" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> David Simcha <dsimcha@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> Discuss the phobos library for D <phobos@puremagic.com><br><b><span style="font-weight: bold;">Sent:</span></b> Friday, April 22, 2011 10:42 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [phobos] Time to get ready for the next release<br></font><br>
<meta http-equiv="x-dns-prefetch-control" content="off"><div id="yiv469585886"><br><br><div class="yiv469585886gmail_quote">On Fri, Apr 22, 2011 at 10:39 AM, Steve Schveighoffer <span dir="ltr"><<a rel="nofollow" ymailto="mailto:schveiguy@yahoo.com" target="_blank" href="mailto:schveiguy@yahoo.com">schveiguy@yahoo.com</a>></span> wrote:<br><blockquote class="yiv469585886gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); 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>
</div><meta http-equiv="x-dns-prefetch-control" content="on"><br>_______________________________________________<br>phobos mailing list<br><a ymailto="mailto:phobos@puremagic.com" href="mailto:phobos@puremagic.com">phobos@puremagic.com</a><br><a href="http://lists.puremagic.com/mailman/listinfo/phobos" target="_blank">http://lists.puremagic.com/mailman/listinfo/phobos</a><br><br></div></div></blockquote></div></div></body></html>