[Oberon] string manipulation
denis.spir at gmail.com
Tue Jun 22 15:45:53 MEST 2010
On Tue, 22 Jun 2010 14:24:23 +0200
"Stauber Sven Philipp" <sven.stauber at inf.ethz.ch> wrote:
> > ... learning the *language*; and to talk about it?
> Be sure you don't miss the A2 Programming Quickstart Guide (http://www.ocp.inf.ethz.ch/wiki/Documentation/Language). Also, there is an Oberon & Active Oberon board on our forum (http://www.ocp.inf.ethz.ch/forum/). On http://www.oberon.ethz.ch/bibliography/publications you'll find some "Programming in Oberon" books. Last but not least, there is a lot of code around...
Thank you, I'll follow the pointers. Actually I knew about the forums, but the one ypu mention does not seem very "active": <<Oberon & Active Oberon Programming Languages 1 Posts 1 Topics>>. Also, mailing list are far more practicle for me.
The core of my interest, as of now, is the *language* Oberon as defined in the Oberon-2 report. I use either 002c or obc to compile for the moment. What is A2, actually? The first sentence of the quickstart guide reads "This is a brief introduction to the programming language Active Oberon and the operating system A2." Implementations including the system or a simulation of it on top of another cannot fit my needs. I may switch to ActiveOberon, again only the language, in a far future, if ever I need to address parallel processing issues, but this is completely outside my field of interests today.
What I'm looking for is a convenient static and compiled language for a project of mine (actually, a language, too ;-) and to build various tools, mainly for the said project. Oberon-2 seems to be close to perfect.
> > If yes, I have a first question: strings are defined as sequences of characters...
> Actually, there are several ways how strings are represented. The simplest one is ARRAY OF CHAR for ASCII strings or UTF-8 encoded strings. In A2, the text system represents characters as LONGINT (Unicode) and strings therefore as ARRAY OF LONGINT.
Right. But the report only seems to use "string" to denote the result of evaluating literal notations like 'abc'. There is no mention of a string type (unlike CHAR). So, I guess there may well be various string representations (and/or types for them) in a given implementation, but they belong to the implementation. Or do I miss a basic point?
If not, the point is then: how are Oberon programmers supposed to deal with strings. ARRAY OF CHAR is an obvious answer but does not hold in practice, since it cannot be the type of a VAR or of a return value. On the other hand, bounded ARRAYs size OF CHAR are not proper types for strings, since very few string variables and return values have a predefined size (indeed, they are the result of input or computation).
In flexible languages, and in most Pascal variants, there is a type corresponding to the notion of a-piece-of-text and to literals denoting instances of it. My aim is to find the corresponding feature in Oberon-2, or a way to construct such a handy representation myself.
In the meanwhile, I'll have a look at the source of A2's String type if it's written in Oberon itself & I can find it.
> > ... which will automatically be 0-terminated
> No, not automatically. It is implementation specific whether some "string" manipulation functions always result in a new "string" (0X-terminated character sequence) or not.
The report explicitely explains that assigning a string (literal) to a var of type ARRAY OF CHAR (which apparently is the only type a var can have to be assigned a string) automagically adds 0X after the string's characters. (The relevant lines of the report are quoted in my original post).
This is what I meant above.
vit esse estrany ☣
More information about the Oberon