[Oberon] LONGINT, RETURN & etc. (Chris Burrows)
Артур Ефимов
arturefimov at gmail.com
Fri Jun 30 13:02:38 CEST 2017
> "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.
>From the syntax point of view, single-character string literals and
character literals look the same in Oberon. One and the same expression "A"
can be interpreted in two different ways by the compiler.
(* "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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20170630/2474f9ba/attachment.html>
More information about the Oberon
mailing list