[Oberon] Clarifying type compatibility in Oberon-07

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Fri Oct 6 13:24:32 CEST 2017


70/30 ;-)


> VAR
>  nbrOfBirthsPerMonth: ARRAY 12 OF INTEGER;
>  nbrOfAccidentsPerMonth: ARRAY 12 OF INTEGER;
>
> nbrOfBirthPerMonth := nbrOfAccidentsPerMonth (* these match
>       structurally but makes not much sense, should be forbidden *)
>
> If you want to write a generic module handling monthly statistics,
> you have open ARRAYs and the exceptions for assignments of actual to formal.
>
> PROCEDURE StoreYear (a: ARRAY OF INTEGER);    (* … *)
>
> StoreYear (nbrOfBirthsPerMonth); (* structural match *)
> StoreYear (nbrOfAccidentsPerMonth);
>
> If you have a procedure like StoreBirths (); you should not
> use open ARRAYs, as then StoreBirths (nbrOfAccidentsPerMonth)
> would be possible…
>
> br
>
> Jörg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20171006/70d0610c/attachment.html>


More information about the Oberon mailing list