PR# 19938 ITERATOR for_each and there_exists violate Command Query Separation

Problem Report Summary
Submitter: brotherbill
Category: EiffelBase
Priority: Medium
Date: 2024/09/04
Class: Bug
Severity: Serious
Number: 19938
Release: 24.05
Confidential: No
Status: Open
Responsible:
Environment: win
Synopsis: ITERATOR for_each and there_exists violate Command Query Separation

Description
for_each and there_exists each have a test argument, returning BOOLEAN.  In addition, the ITERATOR position is short circuited, changing application state of the cursor position.
Both for_all and there_exists should be made obsolete with new queries "all" and "some" which will not affect cursor position.  

search could be used to move the position cursor to the first failing item.

I do not see the strong reason for these two queries to violate the Command Query separation.  If this was intentional, this should have been made obvious by documenting that in the ITERATOR deferred class for deferred methods for_all and there_exists.
The good news is that for_all and there_exists could be made obsolete quickly with a five year retirement date.

This will be a significant change, but violations of Command-Query separation in base libraries should not be taken lightly.

Developers do not expect queries to change state.  There should be a way to both have Command-Query separation and good performance.
Violating Command-Query separation should be explicit, not hidden.

Please fix.
To Reproduce

										
Problem Report Interactions