[Oberon] BYTE to/from INTEGER conversion

Srinivas Nayak sinu.nayak2001 at gmail.com
Wed Jul 6 15:32:27 CEST 2016


In ORB.Mod.txt we see

   PROCEDURE Read(VAR R: Files.Rider; VAR x: INTEGER);

     VAR b: BYTE;

   BEGIN Files.ReadByte(R, b);

     IF b < 80H THEN x := b ELSE x := b - 100H END

   END Read;


and

   PROCEDURE Write(VAR R: Files.Rider; x: INTEGER);

   BEGIN Files.WriteByte(R, x)

   END Write;



Here, Read gets a BYTE from Files.ReadByte(R, b)
and converts that BYTE to INTEGER using IF .. END

But, Write passes the INTEGER directly to Files.WriteByte(R, x)
where prototype of WriteByte is PROCEDURE WriteByte*(VAR r: Rider; x: BYTE);

That means, compiler is able to convert a 4 byte INTEGER implicitly to a 1 byte BYTE,
But the reverse is not possible...

How can I understand this?
Please shed some light on this.


With thanks and best regards,

Yours sincerely,
Srinivas Nayak

Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.in/


More information about the Oberon mailing list