I know that it can't be changed now, because that would break existing code. But I suspect there is code out there that assumes that all will return true on an empty set and is already broken. What I think needs to happen is that this is mentioned in the documentation as a big fat warning, so that people are aware of this unexpected behavior and write code accordingly.
In every other language
all()
(orevery()
) returnstrue
for an empty set (see e.g.every()
in JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every#description). This is because it is defined as (except with short circuiting):https://github.com/jwadhams/json-logic-js/blob/c1dd82f5b15d8a553bb7a0cfa841ab8a11a9c227/logic.js#L317-L319
I know that it can't be changed now, because that would break existing code. But I suspect there is code out there that assumes that
all
will returntrue
on an empty set and is already broken. What I think needs to happen is that this is mentioned in the documentation as a big fat warning, so that people are aware of this unexpected behavior and write code accordingly.