[Oberon] Syntax details.

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Sat Oct 20 19:40:39 CEST 2018


   > What about the second question.
   > Can the result be accomplished without a type cast? [ (TextFrames.Frame) ] 

This is actually a "type guard". It is necessary, since the field .dsc
is defined in Display.Frame and is itself of type Display.Frame. The
field .text s defined in TextFrames.Frame, which is an extension of
Display.Frame. There is no way for the compiler to determine (at
compile time) what the dynamic type of v.dsc will be at run time.
Hence the need for the type guard.

PS: You may want to replace the lines

   Texts.OpenScanner(nameS, v.dsc(TextFrames.Frame).text, 0);
   Texts.Scan(nameS)

with these lines (where F is local variable of type Display.Frame)

    v := Oberon.MarkedViewer(); F := v.dsc;
    CASE F OF
      TextFrames.Frame: Texts.OpenScanner(nameS, F.text, 0); Texts.Scan(nameS)
    END ;

because (in theory) it is possible to have viewers, where v.dsc is not a text frame.

(see ch 9.5 on p.10 in http://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.Report.pdf)

-ap




More information about the Oberon mailing list