On Fri, Apr 22, 2011 at 10:39 AM, Steve Schveighoffer
<[email protected]>wrote:

> Bug reports.  People having stupid arguments just like this one on why you
> should change how the code works to fit their style ;)
>
> 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.
>
> 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
>
> // create a time spand that represents the given number of seconds
> static TimeSpan seconds(int s)
>
> which would be used like this:
>
> auto s = TimeSpan.seconds(5);
>
> But it could also be used as a property.  So this compiled and constructed
> a temporary time span and throw it away:
>
> TimeSpan s;
>
> s.seconds = 5;
>
> So we had to change seconds to fromSeconds.  It still allows code like
> this:
>
> s.fromSeconds = 5;
>
> 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.
>
> -Steve
>
>
Nor should you.  People who are confused should RTFM.  BTW, what if you, as
a library designer, *want* to express the notion that something can be
called both ways?
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to