[Oberon] Compiler behaviour for a32 := a8

Chris Burrows chris at cfbsoftware.com
Wed Feb 3 01:02:48 CET 2021


> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
> August Karlstrom
> Sent: Tuesday, 2 February 2021 9:51 PM
> To: ETH Oberon and related systems
> Subject: Re: [Oberon] Compiler behaviour for a32 := a8
> 
> On 2021-02-02 01:55, Chris Burrows wrote:
> > Note that when the language was updated he did add:
> >
> > 4. An open array may be assigned to an array of equal base type
> >
> > Which should allow you now to write:
> >
> >     TYPE
> >       Ident = ARRAY 32 OF CHAR;
> >     VAR
> >       a8:  ARRAY 8 OF CHAR;
> >       a32: ARRAY 32 OF CHAR;
> >       id1, id2: Ident;
> >
> >   PROCEDURE Assign(VAR dst: Ident; src: ARRAY OF CHAR);
> >   BEGIN
> >     dst := src
> >   END Assign;
> >   ...
> >   ...
> >   Assign(id1, a8);
> 
> How can we conclude from the language report that a shorter array can
> be assigned to id1? Sure, it makes sense for strings but what about
> non-character arrays? The statement above may as well trigger a run-
> time exception.
> 

Because the Language Report does *not* say:

  4. An open array may be assigned to an array of equal base type *and equal
length*

Why prohibit non-character arrays? I have had occasions when I just want to
copy the first couple of elements of a 4-byte array to a 2-byte array.

Regards,
Chris Burrows
CFB Software
https://www.astrobe.com/RISC5






More information about the Oberon mailing list