Derek Parnell wrote:
On Thu, 14 May 2009 17:33:40 -0400, Steven Schveighoffer wrote:
On Thu, 14 May 2009 17:21:02 -0400, Derek Parnell <[email protected]> wrote:
Not really. What could funcA possibly do with the index without the
string itself? If it's just a flag (uint.max or not), then funcA should
be:
funcA(bool found, ...)
and you call it with
funcA(find(needle, haystack) < haystack.length, xyzzy)
This doesn't cause any problems with people who use Tango, which returns
the length if not found. In other words, if you find yourself writing
code to "morph" the length into uint.max or -1, you are thinking about the
problem incorrectly.
Who said that I had control of how funcA() was implemented?
Well, if you wrote
funcA(find(needle, haystack) < haystack.length, xyzzy)
then it is you, who decided to use funcA. Now, if that wasn't to your
liking, you'd of course write your own funcA (or use another function),
that works as you want.
Therefore, you're "in control of funcA() here".