[Oberon] 0X enigma

Christian Demmer chris at gcjd.de-web.ws
Wed Jun 30 11:33:46 MEST 2010

spir wrote:
>I thought and read that 0X is equivalent to ''. It is equivalent for output, since 0X produces none per definition; but its internal representation is not the same. This indeed fools my code (or rather my initial assumption): the init method records an actual content size of 1.

I don't really see a problem here. LEN does not give the content size
but the length of the allocated array. Strings.Length would give the
content size of a string. I don't know the internals of ooc (I think you
use ooc) but as a compiler writer I can imagine what happens. The
implicit conversion of a constant char to a string usually gives a 2
bytes array: one for the char one for the terminating 0X. If the char is
0X you get two 0X in an arrray. I suspect nobody thought of optimizing
this special case.

>Actually, this behaviour may be better, allowing the user to define a String really containing a single char (or byte) that actually holds 0X.
>But I would like to elucidate the enigma anyway.

I don't get it; why this is so important. I see no reason why a
compiler is not allowed to allocate a different amount of array
length from content length.

Greetings, Christian

More information about the Oberon mailing list