[Oberon] Re (n): syntax in BB, CP, GPCP and V4 ...
skulski at pas.rochester.edu
Sun Jul 23 18:45:18 CEST 2017
IMHO, the most perfect formatting was worked out by Robert in his Lib package for BlackBox. Once I saw his programs, I started writing mine the same way. It helped my productivity right away.
Just have a look...
From: Oberon [oberon-bounces at lists.inf.ethz.ch] on behalf of Jörg [joerg.straube at iaeth.ch]
Sent: Sunday, July 23, 2017 2:27 AM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Re (n): syntax in BB, CP, GPCP and V4 ...
Indentation is indeed a totally personal thing.
The compiler doesn’t need indentation at all, you could write your whole module on one line :-)
There are certain indentations N. Wirth uses, I personally don’t like:
Eg. N Wirth starts with the first statement directly behind the BEGIN.
My BEGINs are on their own line, as well as the corresponding ENDs. All line between BEGIN and END are indented by one tab.
I indent procedures as follows
s: ARRAY 20 OF CHAR;
i := 1;
s := „Hello World“;
The procedure header of a top level PROCEDURE is NOT indented, it starts at the beginning of the line.
The CONST, TYPE, VAR, BEGIN and END of the procedure are indented once relative to its procedure header.
If I have one variable, I write it directly behind the VAR. If there are more, I indent all variables once relative to the VAR.
if I have a short statement in an IF, I write the whole IF THEN END on one line as I see it as one construct.
IF i < 100 THEN INC(i) ELSE i := 0 END;
If the statements are longer I put the statements on separate lines indented once relative to its IF END.
If the two parts of the THEN and ELSE are very different in length I prefer a short THEN and a long ELSE. As an example
Instead of this
IF i = 0 THEN
I use this form if possible:
IF i # 0 THEN Error(15)
Am 23.07.2017 um 03:13 schrieb Hans Klaver <hklaver at dds.nl<mailto:hklaver at dds.nl>>:
Peter Easthope wrote:
Is there a convention for indentation? Two blanks for each step?
Four blanks for each step? A tab character for each? Entirely
The only relevant convention that I'm aware of is the text "Programming Conventions" of BlackBox Component Framework, which states under 10 White Space: "A new indentation level is realized by adding one further tabulator character".
This text mostly follows the source code formatting used by prof. Wirth.
In my experience indentation with blanks only works well with monospaced fonts (e.g. Courier).
The Oberon Wikibook and major Oberon textbooks preferably use a proportional font (e.g. Helvetica or Times) for Oberon source text.
Changing a tab character into a fixed number of blanks is done easily automatically, but changing a number of blanks in a text set in a proportional font into the right number of blanks or tab characters for any other font to get a nicely indented text must nearly always be done manually.
Therefore I would suggest to use one tab character for each indentation.
Oberon at lists.inf.ethz.ch<mailto:Oberon at lists.inf.ethz.ch> mailing list for ETH Oberon and related systems
More information about the Oberon