[Oberon] Negative integer literals in Oberon

Chris Burrows chris at cfbsoftware.com
Mon Apr 27 01:55:36 CEST 2020


It is useful that Blackbox reports those compilation errors; it is less forgiving than many Oberon compilers. By not making assumptions it forces the programmer to really think about what he is trying to achieve. 

 

As far as I know there are no specific literal constants defined in Component Pascal for BYTE or SHORTINT values. 

 

If I were you I would implement two completely separate compilers. One that implements 32-bit INTEGERs and another that implements 64-bit INTEGERs and avoid mixing the two. In that way you can still conform to the Oberon Language report and not have to introduce any extensions. If you are concerned that a programmer might want to write code using the 64-bit compiler and then try to run it on the 32-bit compiler that is a problem for the programmer not you. 

 

If the programmer is writing code that he wants to run on both systems then he should separate any parts that are sensitive to the size of INTEGER and include assertions in those parts such as:

 

ASSERT(SYSTEM.SIZE(INTEGER) = 8)

 

to prevent it from accidentally being compiled for, and run on, the wrong platform.

 

Regards,

Chris Burrows

CFB Software

https://www.astrobe.com

 

 

From: dave at brownsmeet.com [mailto:dave at brownsmeet.com] 
Sent: Sunday, 26 April 2020 11:23 PM
To: chris at cfbsoftware.com; ETH Oberon and related systems
Subject: Re: [Oberon] Negative integer literals in Oberon

 

Thanks Chris, that's interesting. I explored some combinations in blackbox:

MODULE Test; IMPORT Out;

PROCEDURE Do*;
VAR b: BYTE; s: SHORTINT; i: INTEGER; l: LONGINT;
BEGIN
  i := 0FFFFFFFFH; Out.String("i := 0FFFFFFFFH: "); Out.Int(i,1); Out.Ln;
  l := 0FFFFFFFFH; Out.String("l := 0FFFFFFFFH: "); Out.Int(l,1); Out.Ln;
  l := 0FFFFFFFFL; Out.String("l := 0FFFFFFFFL: "); Out.Int(l,1); Out.Ln;
  l := 0FFFFFFFFFFFFFFFFL; Out.String("l := 0FFFFFFFFFFFFFFFFL: "); Out.Int(l,1); Out.Ln;
  (* The following all fail to compile with 'number too large': 
    b := 0FFH;
    s := 0FFFFH;
    i := 0FFFFFFFFL;
    l := 0FFFFFFFFFFFFFFFFH;
  *)
END Do;

END Test.

With results:

  i := 0FFFFFFFFH: -1
  l := 0FFFFFFFFH: -1
  l := 0FFFFFFFFL: 4294967295
  l := 0FFFFFFFFFFFFFFFFL: -1

So I understand the H/L suffix enables the use of hex bit patterns for 32 and 64 bit integers, but does not address the issue for 8 or 16 bit integers.

Do you know if there is any way to enable e.g. FF for bytes, or FFFF for shortints? Or whether this was considered?

Thanks -- Dave.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20200427/683e5ccc/attachment.html>


More information about the Oberon mailing list