<html><body><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><div><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:19 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="yiv1786998633"><br><br><div class="yiv1786998633gmail_quote">On Fri, Apr 22, 2011 at 10:11 AM, Steve Schveighoffer<span dir="ltr"></span><br><blockquote class="yiv1786998633gmail_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>In this case, it's not actually the
library designer, but the user of the library that is deciding the
semantics. Big difference, and my huge problem with D's properties.</div>
<div><br>
</div>
<div>With strict properties, the power is to the library designer to
decide on semantics. With loose properties, it's to the user. You can
think you are creating a usable API, but it's still possible to abuse
it.</div>
<div><br>
</div>
<div>In other words, loose properties prevents *my* designs, even if it
makes *your* usage possible. Note that it's your usage, *not* your design
that you are enforcing. The API is beyond your control since the user
is free to call however he/she wants.</div>
<div><br>
</div>
<div>So I think the language shouldn't hinder the library author's designs in favor of the caller abusing usage.<br>
</div>
<div><br>
</div>
<div>-Steve<br></div>
</div></div><br>_______________________________________________<br>
phobos mailing list<br>
<a rel="nofollow" ymailto="mailto:phobos@puremagic.com" target="_blank" href="mailto:phobos@puremagic.com">phobos@puremagic.com</a><br>
http://lists.puremagic.com/mailman/listinfo/phobos<br></blockquote></div><br>If you look at it this way, then I fail to see the problem with a little abuse. The library designer doesn't have to read the caller's code. Why should he/she care if the API is being abused a little?<br>
</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>