[Oberon] Clarifying type compatibility in Oberon-07

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Thu Oct 12 14:35:02 CEST 2017


> On Thu Oct 12 14:17:17 CEST 2017 Chris Burrows wrote:
>
> In May 2016, the Oberon array assignment rule was relaxed
> with the addition of the following rule:
> 
> "9.1.4. An open array may be assigned to an array of equal base type.”
> 
> Since that time you have been able to write:
>
> PROCEDURE P(s: ARRAY OF CHAR); 
>   VAR local: ARRAY 255 OF CHAR; 
> BEGIN local := s; 
> END P;
>
> The downside of this is that the declaration of the local array has
> to be large enough to handle the largest array that might be passed to the procedure. This could lead to inefficient stack usage.
>

Do you know the reason why the inverse operation, i.e. assignments *to* open arrays, is not supported? I.e. the operation

  PROCEDURE Q(s: ARRAY OF CHAR); 
    VAR local: ARRAY 255 OF CHAR; 
  BEGIN s := local 
  END Q;

or even

  PROCEDURE R(s, t: ARRAY OF CHAR); 
  BEGIN s := t 
  END R;

In all three cases (P, Q and R) the assignments would be rather easy to implement in the compiler,
as the length of the open array is always passed on the stack anyway (code pattern 10 in section
12.2. in the book Project Oberon) and therefore easily accessible. And in all three cases the
check whether the length of the source is <= the length of the destination cannot be done at
compile anyway, but needs to be done at runtime.

-AP




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20171012/2faf78e3/attachment.html>


More information about the Oberon mailing list