[Oberon] library & recursion & ^

easlab at absamail.co.za easlab at absamail.co.za
Mon May 22 07:47:34 CEST 2006


Original 'Subject:' text lost due to new-age emailing methods.

On 5/19/06, shark at gulfnet.sd64.bc.ca <shark at gulfnet.sd64.bc.ca> wrote:
> I want to understand the "built in" functions
> (if that is the correct terminology) better.
> CAP( ) for example.  Appears it is defined in
> OPB.Mod.  Ie.
>
> | cap:
>                 IF f = Char THEN
>                         IF z^.class = Nconst THEN
>                                 z^.conval^.intval := ORD(CAP(CHR(z^.conval^.intval)));
>                                 z^.obj := NIL
>                         ELSE z := NewOp(op, typ, z)
>                         END
>                 ELSE err(111); z^.typ := OPT.chartyp
>                 END
>
> Can anyone shed a little light on this?
> With ORD(CAP(CHR(z^.conval^.intval)))
> present, how is this not a recursive definition?

Thomas wrote:
T] This is just the compile time evaluation of a "CAP" of a constant
T] value in the source code like e.g. "CAP('x')". This offline evaluation
T] is of course more efficient than loading the constant at run time and
T] then performing the capitalization. The result of the evaluation is
T] copied into the object file but not the code to perform the evaluation
T] at run time.
T] The use "ORD(CAP(CHR(z^.conval^.intval)))" is not really recursive, it
T] is just the compiler using CAP to evaluate a constant CAP in the
T] source code. Normally (for variables) the z := NewOp(op, typ, z)
T] branch is taken and the evaluation code for CAP is compiled into the
T] 

This raises several questions:

Q1. what language is this ? Looks a bit like pascal.
  Has Aos/Blue-bottle introduced more new syntax ?
"The result of the evaluation" suggest that this syntax
applies only to the 'compiler' as explained above - no ?

Q2. why does Thomas post emails by base64 decoding ?
Am I missing more of the advantages of modern methods ?
The funny-stuff coming by email these days [eg. multiple
decodings for char(<quote/single & double>)] makes the arrival 
of unix-ETH-oberon very fortunate.  Since the N-O inet tools
require extra text processing to restore plain text [as existed
years back with no problems].

Certainly defining CAP(arg) as
ORD(CAP(CHR(z^.conval^.intval)))
is a 'recursive definition'.
And in natural-language/logic that is inadmissible.
But the code shown, has the 'exit-branch'
   ELSE z := NewOp(op, typ, z).
So the code only recurs as long as 
  z^.class = Nconst 
is satisfied, and then 'unwinds' the recursion when the
 ELSE {z^.class 'is NOT' Nconst}; condition exists,
which is how recursion works in computing.
Ie. there must be an exit route/branch to stop the
recursion.

 == Chris Glur.

PS. re. need linux inet tools for use with linux-ETH-oberon,
I've just discovered pan: the Newsreader clone of Agent.
IMO Agent was the best [most intuitive] news reader.
Do any other readers use pan ?
My version [with FC1] seems a bit slow & cluncky.
But the web-site seems to suggest that no updates were made
for a long time.

PSS. pan is similar to mc as an example of cloning good 'panel-based'
applications from other OSs ?



More information about the Oberon mailing list