How ANY and ALL In Other Languages Act on Empty Inputs

I was looking around in the "Red Enhancement Process" repository to see if there was anything there of interest, and one thing that's at least useful was a survey of how other language constructs paralleling ANY and ALL act when given empty inputs.

The repository is BSD-licensed and so I'll reproduce the list here. :stuck_out_tongue:


Red

>> all [] == none
>> any [] == none

Rebol2 & Rebol3:

>> all [] == true
>> any [] == none

Scheme:

(and) #t
(or) #f

Common Lisp:

(and) T
(or) NIL

R:

all() [1] TRUE
any() [1] FALSE

J:

*./>a: 1
+./>a: 0

Julia:

all([]) true
any([]) false

Python:

all([]) True
any([]) False

Javascript:

[].every(function(){}) true
[].some(function(){}) false

Lotsa Precedent For ALL [] Truthy, ANY [] Falsey...

If you squint hard enough, there are legitimate reasons for favoring this choice--if both have to be constrained to just TRUE and FALSE.

The arguments sort of parallel why it's reasonable to say that TRUE > FALSE. But it's sort of abstract...and you wind up talking about "mathematical consensus regarding bounded lattices…more specifically, a complemented distributive lattice."

...BUT...We Can Do Better, With VOID

The idea behind VOID (as opposed to NIHIL) is that a function can say that in spirit it produced nothing, but still give back some result... a representation of void intent. Some contexts like the condition of an IF will error on voids. But others like ANY and ALL will consider it "no vote" and skip it.

I think that the fact ANY [] and ALL [] have kind of eluded a standardized consensus in the Redbol world considers that historically they didn't come up in practice much.

BUT I've got some powerful use cases coming up to demonstrate that take advantage of the ability to erase results of ANY and ALL. These use cases blow away any microscopic benefit given by declaring the answers here to be true or false. And for ALL to be truthy it would have to lie in some way--by fabricating an arbitrary truthy value.

You won't have to take my word for it that this is a big win...see for yourself:

:eye: :pig_nose: :eye:

2 Likes