[Oberon] SYSTEM Modules

Richard Hable informujo at aon.at
Mon Nov 12 20:15:43 CET 2018


On 12.11.18 06:40, Jörg Straube wrote:
> You‘re right. It’s not the safety I‘m referring to but rather the
> portability.
> 
> Eg n := ORD(ch) - ORD(“A“); Out.Ch(ch); Out.String(“ is the “); 
> Out.Int(n, 0); Out.String(„th character.);
> 
> Will work with ASCII but not with EBCDIC.

Maybe we should define portability as "portable as long as the
programmer does not rely on undefined behavior"—like assuming a specific
ordering of character codes in this case.

And even the most portable programming languages contain undefined
behavior. For example, the following Java code comparing references to
objects of type Integer prints "equal" on my local installation:

	Integer x = 6;
	Integer y = 6;
	System.out.println(x == y ? "equal" : "not equal");

However, the following code prints "not equal":

	Integer x = 666;
	Integer y = 666;
	System.out.println(x == y ? "equal" : "not equal");

This is, because the implementation choses to re-use small integer
objects, but allocate new objects for bigger objects. Other correct Java
implementations may just as well chose to cache all values or none at all.

Code which relies on one of these behaviors is potentially unportable;
but that does not make Java's reference comparison feature unportable.

Richard


More information about the Oberon mailing list