[Oberon] "built in" functions

Thomas Frey thomas.frey at alumni.ethz.ch
Fri May 19 20:09:28 CEST 2006


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?

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


--Thomas


More information about the Oberon mailing list