'Simple' Assignment

Topics related to the use of Oberon language features
Locked
4GlCoder
Posts: 27
Joined: Fri Jul 22, 2011 2:47 pm

'Simple' Assignment

Post by 4GlCoder » Sun Aug 14, 2011 7:05 pm

MODULE test;
IMPORT SYSTEM;
CONST
ByteV = 22;
VAR
aByte : SYSTEM.BYTE;
BEGIN
aByte := SYSTEM.VAL(SYSTEM.BYTE,ByteV);
END test.

The above code does work, but I find it hard to justify the needed SYSTEM.VAL type cast on a constant value.
where aByte := ByteV should do.
I think this just forces lazy/sloppy programming: Ok just slap in an INTEGER instead of a BYTE and it works. (without the type cast and without the !type cast! message..

cfbsoftware
Site Admin
Posts: 493
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: 'Simple' Assignment

Post by cfbsoftware » Fri Feb 15, 2013 12:37 pm

In Astrobe v4.3 and later BYTE is a regular data type so the above example can be written more simply as:

Code: Select all

MODULE Test;
CONST
  ByteV = 22;
VAR
  aByte: BYTE;
BEGIN
  aByte := ByteV
END Test.

Locked