[Oberon] Character arrays equality

Артур Ефимов arturefimov at gmail.com
Tue Apr 16 17:39:44 CEST 2019


In section 8.2.4 of "The Programming Language Oberon" ("Relations") we read:

Relations are Boolean. The ordering relations <, <=, >, >= apply to the
numeric types, CHAR, and character arrays. The relations = and # also apply
to the types BOOLEAN, SET, and to pointer and procedure types.

I have a few questions on character arrays specifically.

1. Is expression "ABC" = "ABC" correct and does it evaluate to TRUE? (This
might be important in some cases.)
2. What if one of the character arrays is a variable and not a constant?
3. What if both character arrays are variables?
4. What if those character arrays (variables) have different length, though
they hold logically-equal null-terminated strings?
5. What if one (or both) of the character arrays is an open array with
different lengths?

For example:
VAR a, m: ARRAY 5 OF CHAR;
  i: INTEGER;
BEGIN
  FOR i := 0 TO 4 DO a[i] := 0X; m[i] := 0X END;
  a[0] := "A";
  m[0] := "A"; m[3] := "M";
  IF a = m THEN ... END
END

Should we only compare characters before the first 0X?

Thanks!
Arthur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20190416/a934c039/attachment.html>


More information about the Oberon mailing list