[Oberon] LONGINT, RETURN & etc. (Chris Burrows)

Chris Burrows chris at cfbsoftware.com
Sat Jul 1 02:16:00 CEST 2017


Yes – we now agree about that particular example:
 
  RETURN " "

However, there is a difference between Oberon and Oberon-2 related to character and string constants. E.g. the alternative form using single-quotes:

  RETURN ' '

is valid in Oberon-2 but not in Oberon. Double-quotes are the only characters now that can be used to start and end a string literal or character constant. There was a short period in the evolution of Oberon-07 where double quotes were used to denote strings and single-quotes used to denote characters (or vice versa - I don't quite recall) but as you point out it is now longer necessary to make that distinction. The compiler is now able to unambiguously resolve the various scenarios. 

Regards,
Chris Burrows
CFB Software
http://www.astrobe.com


From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of ????? ??????
Sent: Friday, 30 June 2017 8:33 PM
To: oberon at lists.inf.ethz.ch
Subject: Re: [Oberon] LONGINT, RETURN & etc. (Chris Burrows)

> "Single-character strings can also be assigned to variables of type CHAR."

Yes, I thought about that, but only after I had sent the message. A single character string can be returned, as it may be interpreted as a character literal. Oberon 2 isn't different to other versions of Oberon in this sense.

(* "A" is interpreted as ARRAY OF CHAR *)
VAR s: ARRAY 10 OF CHAR;
BEGIN COPY("A", s)   (* or s := "A" in Oberon-07 *)

(* "A" is interpreted as CHAR *)
VAR ch: CHAR;
BEGIN ch := "A"

This is not a problem, as the compiler handles this with a simple IF statement (something like "IF (char expected) & (type = string) & (length = 1) THEN type := char END"). This may be more tricky in case of constants:
CONST x = "A";
There is nothing about this in the language report; however, Oberon compilers handle these situations very well.

Arthur Efimov



More information about the Oberon mailing list