[Oberon] Clarifying type compatibility in Oberon-07

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Sun Oct 8 07:57:15 CEST 2017


> On Sun Oct 8 07:26:20 CEST 2017 Jürg wrote:
>
> Unnamed entities (or is it structural equivalence?) can create troubles. See yourself
> 
> TYPE DotType = PROCEDURE (col, x, y: INTEGER);
> VAR dot: DotType;
> 
> PROCEDURE myDot(x, y, col:: INTEGER); BEGIN END myDot;
> 
> dot := myDot; (* allowed in Oberon, structurally equivalent, but the formal parameters are totally scrambled *) 
>

This is because in Oberon-07 the parameter names are treated as dummies during procedure assignments, i.e. only the types are checked by the compiler. Their names only serve to document to the reader of the program what they might mean. 

This exact same discussion took place within the Swift language development group some time ago. In the end, Swift also went the Oberon-07 way. There, every function has a “function type”, which is made up of the parameter types and the return type of the function, but not their names. So DotType in the example above would have a function type (Int, Int, Int). Including names has been considered as "too restrictive”. But it can lean to weird situations such as the one outlined above. The burden is on the programmer.

-AP




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20171008/4155135c/attachment.html>


More information about the Oberon mailing list