PR# 2877 Conceptual problem within class COUNTABLE_SEQUENCE.

Problem Report Summary
Category: EiffelBase
Priority: Low
Date: 2001/07/10
Class: Feature Request
Severity: Non-critical
Number: 2877
Release: 4.5.020
Confidential: No
Status: Open
Environment: Windows NT 4.0
Synopsis: Conceptual problem within class COUNTABLE_SEQUENCE.

I have a "conceptual" problem with some features in the class COUNTABLE_SEQUENCE.

The features that I feel there are problems with are: has(), index_of(), occurrences(), and search().  These are all defined in one ancestor or another, and they are all effective in LINEAR, a direct ancestor.

The problem is that none of these features is guaranteed to terminate when used.  There is no way to ensure that the input value is present within the sequence.  When supplying a value that is in fact not in the sequence, each of these routines, as written, will either enter an infinite loop or cause an exception when applicable.  The i_th() feature in PRIMES raises an exception on a loop variant, which causes the routines that call it to fail.  The features in FIBONACCI will infinite loop.

This isn't as big a problem with the has() feature, because it's redefined into a safe version, and sometimes renamed, in each of the descendants supplied in EiffelBase: PRIMES, RANDOM, and FIBONACCI.  These will all terminated regardless of the input.

I'm calling this a conceptual problem because none of these features are applicable to infinite sequence, in my opinion.  Asking for the number of times a value occurs in an infinite sequence is, in general, impossible to solve.

My feeling is that these features should be exported to NONE within class COUNTABLE_SEQUENCE.  I think this also affects the object comparison features (compare_objects, etc), because this kind of comparison is no longer applicable.

I think I am correct in this thinking, but if I have missed something, please let me know.

Thank you,
Steve Wurster
To Reproduce
One way to go into an infinite loop would be to run the query occurrences() on class FIBONACCI with any number that is not a Fibonacci.  The feature will never return because the query exhausted will never be True.

In order to raise an exception in PRIMES, run the query occurrences() an any number.  Note that loop variant checking must be enabled.
Problem Report Interactions
From:    Date:2001/07/10    Download