[Oberon] Clarifying type compatibility in Oberon-07

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Wed Oct 11 00:48:02 CEST 2017


> ---------------------------------------------------
> On Fri Oct 6 12:40:42 CEST 2017 Jörg Straube:
> 
> Personally, I’m not indifferent ☺
> 
> I know that it can be done, but the question is WHY. Only because
> something can be done is a poor reason to do it.
>
> If you put  a := b in your code,  you do that as you know or assume
> a certain relationship between those two variables (they e.g. represent
> instances of the same or comparable thing). If this hold true,
> I don’t understand why you have to write two totally independent
> type declarations that (by accident) match structurally.
>
> ---------------------------------------------------
> On Fri Oct 6 13:20:09 CEST 2017 Jörg Straube wrote:
>
>   VAR
>     nbrOfBirthsPerMonth: ARRAY 12 OF INTEGER;
>     nbrOfAccidentsPerMonth: ARRAY 12 OF INTEGER;
>
>    nbrOfBirthPerMonth := nbrOfAccidentsPerMonth (*these match structurally but makes not much sense, should be forbidden*)
>
> ---------------------------------------------------

Jörg,
as I said earlier, I agree that you kind of have a point here. HOWEVER, how is your example conceptually different from:

  VAR
    nbrOfBirthsPerMonth: INTEGER;
    nbrOfAccidentsPerMonth: INTEGER;

    nbrOfBirthsPerMonth := nbrOfAccidentsPerMonth; (*allowed, but *also* makes not much sense*)

or from this:

  TYPE Births = INTEGER;
    Accidents = INTEGER;

  VAR
    nbrOfBirthsPerMonth: Births;
    nbrOfAccidentsPerMonth: Accidents;

    nbrOfBirthsPerMonth := nbrOfAccidentsPerMonth; (*allowed*)

both of which are allowed in Oberon (the second variant is allowed, because in Oberon type aliases are considered as the *same type*), but “make no sense” according to your logic?

In other words: If we *really* were to take a purist point of view (which I am NOT advocating!!), we might as well have the same discussion for the basic types such as INTEGER, i.e. without even referring to structured types (arrays or records).

Just saying...
-AP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20171011/d8edeed9/attachment.html>


More information about the Oberon mailing list