[Oberon] LONGINT, RETURN & etc.
chris at cfbsoftware.com
Fri Jun 30 10:33:40 CEST 2017
RETURN " " END
Actually IS valid in the current revision of Oberon (a.k.a. Oberon-07) because as stated in paragraph 2 of Section 9.1 "Assignments" of "The Programming Language Oberon" (Revision 1.10.2013 / 3.5.2016):
"Single-character strings can also be assigned to variables of type CHAR."
The complete (albeit not very practical) example would be:
PROCEDURE Blank(): CHAR;
RETURN " "
The rules are different in the Oberon-2 language which is what you might be thinking of.
From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of ????? ??????
Sent: Sunday, 18 June 2017 8:02 PM
To: oberon at lists.inf.ethz.ch
Subject: [Oberon] LONGINT, RETURN & etc.
> RETURN " " END is valid
This is not valid, because in Oberon, a functional procedure can not have ARRAY OF CHAR as return type (nor can it return a RECORD). The valid return types are INTEGER, REAL, CHAR, BOOLEAN, SET, POINTER TO ...
"RETURN END" is not a valid construct in an Oberon program not because of the because of the syntax rules, but because of the semantic rules. To show the difference, consider this statement:
IF '5' < 10 THEN END. This is an absolutely valid statement syntaxically, but it is not valid because of the type mismatch (you can't compare expression of type CHAR to an expression of type INTEGER).
> LOOP would be a more generic way iso using REPEAT and/or WHILE.
LOOP can not replace REPEAT and/or WHILE. LOOP + IF can, but not LOOP by itself.
If you want to make the Oberon compiler restrict programmers to only use IF ... THEN EXIT END statement in the beginning or in the end of the LOOP statement, and only once, then the source code of the compiler will get a lot more complex, as this would no more be a syntax rule, but a semantic rule.
More information about the Oberon