[Oberon] ORD for typecasting Pointers (was: Module Fonts without reference to SYSTEM)

Chris Burrows chris at cfbsoftware.com
Sat Sep 5 06:21:12 CEST 2020

> -----Original Message-----

> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of

> Pirklbauer

> Sent: Saturday, 5 September 2020 5:35 AM

> To: Oberon List

> Subject: [Oberon] Module Fonts without reference to SYSTEM


> Below is one way to do it. It used ORD for pointers (undocumented



If not a bug, at best I would classify the ability to use ORD to typecast a
pointer to an INTEGER as a 'loophole'. Refer to the Section titled
'Loopholes' in 'Good Ideas, Through the Looking Glass', Niklaus Wirth 2005.




This loophole is exploited in several modules in Project Oberon. Fortunately
all but one occurrence can be eliminated by replacing ORD(...) with
SYSTEM.VAL(INTEGER, ...) as all of those modules already import SYSTEM. 


The remaining occurrence is in Texts.WriteReal 


  e := ASR(ORD(x), 23) MOD 100H;  (*binary exponent*)


Texts does not already IMPORT SYSTEM. However, that does not matter as a
more suitable replacement in this instance is: 


  UNPK(x, e); 



Chris Burrows

CFB Software



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

More information about the Oberon mailing list