Loading ...
Sorry, an error occurred while loading the content.

SmallEiffel (-0.76): STRING.index_of does not conform to ELKS 2000

Expand Messages
  • Ulrich Windl
    Hello, I noticed that SmallEiffel s index_of returns count + 1 if the character was not found, but ELKS requies 0 to be returned. SmallEiffel: index_of(ch:
    Message 1 of 2 , Dec 5, 2000
    • 0 Attachment
      Hello,

      I noticed that SmallEiffel's index_of returns "count + 1" if the
      character was not found, but ELKS requies "0" to be returned.

      SmallEiffel:
      index_of(ch: CHARACTER): INTEGER is
      -- Gives the index of the first occurrence `ch' or
      -- `count + 1' if none.
      do
      Result := 1 + storage.fast_index_of(ch,count - 1);
      ensure
      (Result /= count + 1) implies (item(Result) = ch);
      end;

      Regards,
      Ulrich
    • Arno Wagner
      ... Hi Ulrich, I seem to remember we had some discussion about the result of index_of here. Another option was to just require valid_index(index_of(ch)) to
      Message 2 of 2 , Dec 6, 2000
      • 0 Attachment
        --- Ulrich Windl" wrote:
        > Hello,
        >
        > I noticed that SmallEiffel's index_of returns "count + 1" if the
        > character was not found, but ELKS requies "0" to be returned.
        >
        Hi Ulrich,

        I seem to remember we had some discussion about the result of
        'index_of' here. Another option was to just require
        'valid_index(index_of(ch))' to be false in case 'ch' is not
        contained in the string. The final decision was taken becaues
        '0' is a fixed value, as far as I remember.

        As I am in charge of making SE STRING ELKS2001 compliant (as soon
        as ELKS2001 is finished), you can rest assured that this will be
        corrected. At the moment STRING is still in the works and some
        features have to be revisited before it can be finished, so it
        would probably be a bad idea to make incomplete changes now.

        In the meantime the query with 'valid_index' should be
        used for compatibility. It might also be a sensible choice
        to use 'valid_index' in general for these queries.

        Regards,
        Arno
        ------
        Arno Wagner Dipl. Inform. ETH Zuerich wagner@...
        GnuPG:ID:F0C049F1 FP:8C E0 6F A5 CC B1 5A 11 ED C7 AD D2 05 5E BB 6F
        "This software comes with ABSOLUTELY NO WARRANTY. Even if it erases
        your hard drive, too bad. Although we did fix that bug from the last
        release." --README from a long-ago release of DJGPP
      Your message has been successfully submitted and would be delivered to recipients shortly.