Skip to content

all_of and all_of_proc return false for empty slices #6052

@shmadchenko

Description

@shmadchenko

Context

I have observed a potentially unintended behavior in the slice package.
The procedures all_of and all_of_proc currently return false when called on empty slices.

In most other programming languages and libraries, similar functions return true for empty containers.
This behavior aligns with the principle of vacuous truth in logic.

For comparison, see:
C++: std::all_of
C# / .NET: Enumerable.All
Python: all()

The current behavior may be counterintuitive and can lead to subtle bugs when developers assume that all_of behaves consistently with similar functions in other languages.

Consider updating the implementation of all_of and all_of_proc so that they return true for empty slices, in accordance with the standard behavior observed in other languages and the logical expectation.

Expected Behavior

all_of and all_of_proc return true when called on empty slices.

Current Behavior

all_of and all_of_proc return false when called on empty slices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions