AW: [Oberon] string manipulation

Stauber Sven Philipp sven.stauber at inf.ethz.ch
Tue Jun 22 17:19:11 MEST 2010


Hi,


>>> 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?

No, you're right. For those Oberon implementations (e.g. Native Oberon, A2, ...) I've seen, string representation and manipulation is mainly part of the Oberon "system", not the Oberon language.

The only things the Oberon language provides:

- string literals 
- built-in COPY function
- Operators: = # < <= > >= also work on 0X-terminated "strings"

More advanced string manipulation features as appending a string to another, for example, are implemented as library (as Strings.Mod in Native Oberon/A2). Even more advanced features as text representation are again part of the implementation.

Best,
Sven

-----Ursprüngliche Nachricht-----
Von: oberon-bounces at lists.inf.ethz.ch [mailto:oberon-bounces at lists.inf.ethz.ch] Im Auftrag von spir
Gesendet: Dienstag, 22. Juni 2010 15:46
An: oberon
Betreff: Re: [Oberon] string manipulation

On Tue, 22 Jun 2010 14:24:23 +0200
"Stauber  Sven Philipp" <sven.stauber at inf.ethz.ch> wrote:

> Hi,
> 
> > ... 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 ☣

spir.wikidot.com
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon


More information about the Oberon mailing list