<div dir="ltr"><div>Yes I agree, as I mentioned in my last email my solution has a cost.</div><div>If we have to restrict the CASE probably I would rather pay the extra runtime cost or remove this type functionality of the CASE altogether.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 30, 2020 at 9:37 AM Andreas Pirklbauer <<a href="mailto:andreas_pirklbauer@yahoo.com">andreas_pirklbauer@yahoo.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">    > I remember reading about a similar issue related to the WITH statement of<br>
    > Oberon-90, so the way I solved this problem in oberonc is to add an additional<br>
    > type test each time the case variable is referred in the statements of a particular case label.<br>
<br>
Hi Luca,<br>
<br>
Yes, that’s of course the obvious solution. But that would re-introduce run-time<br>
overhead that the type case statement avoided in the first place. In that case, one<br>
might as well get rid of the CASE altogether and just use IF p IS T THEN instead:<br>
<br>
i.e. replace...<br>
<br>
  PROCEDURE check0();<br>
    BEGIN p0 := p1;<br>
    CASE p0 OF<br>
      P1:<br>
        AssignGlobal();<br>
        p0*(P1)*.fld1 := 123; <br>
    END<br>
  END check0;<br>
<br>
with...<br>
<br>
  PROCEDURE check0();<br>
    BEGIN p0 := p1; <br>
    IF p0 IS P1 THEN<br>
        AssignGlobal();<br>
        p0*(P1)*.fld1 := 123; <br>
    END<br>
  END check0;<br>
<br>
My (proposed) solution rescues the CASE statement (which is efficient relative<br>
to IF x IS T + series of additional type tests inside the IF statement), while at<br>
the same time solving its type loophole issues.<br>
<br>
But I would not mind eliminating the type case statement and just have type guards.<br>
<br>
-ap<br>
<br>
<br>
<br>
--<br>
<a href="mailto:Oberon@lists.inf.ethz.ch" target="_blank">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<br>
<a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" rel="noreferrer" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/oberon</a><br>
</blockquote></div>