We are both making assumptions about how "[o]ne would use the result",
Not at all. I'm saying you shouldn't introduce bugs in the design of a function based on the assumption that someone might misuse it.
If you can handle cases of misuse without compromising the design, that's great, but that's not possible here.
Any usage of the sub in scalar context will behave as expected
Correct. «return ();» in scalar context functions identically to «return undef;». That makes the behaviour in list context the deciding factor.
It only needs to be converted to a boolean first if it is used in a list assignment.
No. Here's an example without an assignment:
{ foo => validate($foo), bar => validate($bar) }
When using «return ();», the result needs to be converted to a boolean whenever validate is called in list context. That makes no sense for a function that's suppose to return a boolean.
|