[Oberon] FPGA - ORP.Compile * `marked viewer'

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Tue Apr 25 18:35:00 CEST 2017


Paul,


I have to disappoint you. I’m not engaging in a race to indiscriminately add new features to the Oberon system (that would be against the very spirit of Oberon, wouldn’t it?). Thinking about it though, I would probably recommend to refrain from adding a procedure MarkedViewerText() to module Oberon because it would either require module TextFrames to be imported in module Oberon (which however is the top module of the outer core and therefore is not supposed to contain TextFrames - wrong place!) or require placing MarkedViewerText within ORP itself, which in turn would trigger the import of modules Viewer and TextFrames. Not pretty either. The only remaining option then would be to create a new System.Compile command just for that one purpose (namely of accepting the “*” option) and move MarkedViewerText up to module System instead. Three unappealing options!


But if one really *wanted* to add the “*” option, it would of course be straightforward:


  PROCEDURE MarkedViewerText* (): Texts.Text;

    VAR V: Viewers.Viewer; T: Texts.Text;

  BEGIN V := Oberon.MarkedViewer();

    IF (V.dsc # NIL) & (V.dsc.next # NIL) & (V.dsc.next IS TextFrames.Frame) THEN T := V.dsc.next(TextFrames.Frame).text

    ELSE T := NIL

    END ;

    RETURN T

  END MarkedViewerText;


and then in ORP.Compile:


   ELSIF S.c = "*" THEN T := MarkedViewerText();

     IF (T # NIL) & (T.len > 0) THEN ORS.Init(T, 0); Module END
      
   END


Then one can first designate any (text) frame as operand by placing the star marker in it and activate the command ORP.Compile * . It does work. But does one need it?


Again, I would not recommend adding it. If someone finds an elegant solution to this, I’d reconsider. And if someone forced me to add it, I would probably go the route via a new command System.Compile and move MarkedViewerText up to module System (even though it does not belong there). This would keep both modules Oberon and ORP free of unwanted imports.


Andreas


---------------------------------------- 


Paul Reed paulreed at paddedcell.com <http://paddedcell.com/> Tue Apr 25 16:16:14 CEST 2017


Hi Tomas,


Not sure if useful, but is there a way to add * marked viewer as a parameter to ORP?

> ORP.Compile ~ is there

> ORP.Compile ^ (make sense?)

> ORP.Compile @ is there

> ORP.Compile * to add


I assume Prof. Wirth removed (or didn't add, he seems to write a lot of
his compilers freshly from scratch) the "marked viewer" version of the
compiler parameter handling because it removes the need for dependencies
on the imports Viewers and TextFrames (and the fiddly walk down the viewer
hierarchy to find the marked text).


As an exercise you could add the feature back in to ORP.Mod if you wish,
by referring to the code in the original edition, in Compiler.Mod.


(BTW you may notice that Edit.Locate has been changed too, to use the
FocusViewer instead of the MarkedViewer - though not for the same reason).


It might perhaps have been better, in hindsight, if the Oberon module had
exported a function Oberon.MarkedViewerText().  No doubt Andreas has
already added it... ;-)


HTH

Paul

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20170425/19d2968a/attachment.html>


More information about the Oberon mailing list