[Oberon] Clarifying type compatibility in Oberon-07

Jörg joerg.straube at iaeth.ch
Thu Oct 5 17:25:20 CEST 2017


Hi Andreas

 

Of course we could do so, but I wonder why?

If I understand you correctly you want to allow the following

VAR

a: ARRAY 30 OF CHAR;

b: ARRAY 30 OF CHAR;

a := b;

 

Currently, this is not allowed, because there are several ways to allow this already

Method 1:

VAR a, b: ARRAY 30 OF CHAR;

Method 2:

TYPE String30 = ARRAY 30 OF CHAR;

VAR

a: String30;

b: String30;

 

We should not change the language. At least not in this case. What could be a practical benefit of it?

NW allows assignment of different ARRAY types only in case of open arrays. This is reasonable as the formal parameter accepts different types.

 

PROEDURE Test(VAR open: ARRAY OF CHAR);

                VAR local: ARRAY 17 OF CHAR;

                BEGIN

                               local := open  (* exception allowed by report *)

                               open := local (* not allowed. Here we could discuss whether we should allow this as well *)

END A;

 

Jörg

 

Von: Oberon <oberon-bounces at lists.inf.ethz.ch> im Auftrag von Andreas Pirklbauer <andreas_pirklbauer at yahoo.com>
Antworten an: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Datum: Donnerstag, 5. Oktober 2017 um 16:38
An: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Betreff: Re: [Oberon] Clarifying type compatibility in Oberon-07

 

EDIT:

 

Assignment compatible

…

*8. Tv is ARRAY n OF Ta, e is ARRAY OF Tb, where Ta and Tb are the same type

 

 

On 05 Oct 2017, at 16:31, Andreas Pirklbauer <andreas_pirklbauer at yahoo.com> wrote:

 
> On Thu Oct 5 12:52:20 CEST 2017 Jörg joerg.straube at iaeth.ch wrote:
> Assignment rule 1 uses „same type". The things NOT covered by „same type“ are mentioned explicitly with own assignment rules.
> 
> 4. Ta and Tb are pointer types whose pointer base types are the same, or
> This rule is not needed, as it is covered by Assignment rule 4, assuming T is an extension of T itself.
> 5. Ta and Tb are procedure types whose formal parameter lists match.
> This rule is not needed as it covered by Assignment rule 7.
> 
> br
> Jörg
Ok. So these two proposed rules are not needed (assuming T is an extension of T itself).


While we are at it, what about the following similar rules for arrays (changes are marked with an asterisk * below). Would these be covered by the existing type rules and/or can these be derived from the language report? If these rules cannot be derived from the language report, should the language itself be extended?


Same Types
Two variables a and b with types Ta and Tb are of the same type if
...
*4. Ta and Tb are array types with same element types and lengths
 
Assignment compatible


An expression e of type Te is assignment compatible with a variable v of
type Tv if one of the following conditions hold:
...
*8. Tv is ARRAY OF Ta, e is ARRAY OF Tn, where Ta and Tb are the same types
 
-AP
 

-- Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20171005/5968cb55/attachment.html>


More information about the Oberon mailing list