by hinkley · 7y ago · 0 comments
jQuery made a similar observation, and many of its functions are list comprehensions. If they had chosen a different default behavior for empty lists I might still be championing it today. But the silent failures were a bitter pill to swallow.
In fact I sometimes still fantasize about building a mini front end framework containing the inverse behavior and some other more modern ideas.
I meant fail on an operation on an empty set. The number of times that I’ve had a potentially empty set is a fraction of all situations. Often a select all/select none situation, and adding a flag for silent failure in that case is cheap compared to all of the other bugs I’ve had to fix.
Also variance disagrees with you. A function that takes a single value may be generalized to take multiple values but it’s harder for a caller that expects a single value in return to be faced with multiple answers.
If I ask for your shipping address and get three, I can’t send the package to three places. I have to change the workflow quite a bit.