Hacker News new | past | comments | ask | show | jobs | submit login

You'd just open another debate.

Your client code has to work with the behaviour of your function.

If you have a perfectly sensible answer for a corner case, just give that answer. Otherwise, you are forcing unnecessary extra case handling on your client code.

And that principle also tells you which answer your code should be giving: whatever makes the client code simpler.

Another example, perhaps more inspired from C conventions:

Imagine you have some functions that take a timeout as an argument. After the time is up, they should fail, if they haven't produced an answer yet.

Now, in these kinds of situations you often find that people choose 0 to mean an infinite timeout.

That's a bad idea, because it violates simple invariants like: if you run two statements with timeouts of t0 and t1, after at most t0 + t1 seconds, you should either have an answer or get an error.

(You can of course complicate the invariant by adding special cases for t0 or t1 being zero. But who likes special cases?)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: