[Oberon] Re (n): syntax in BB, CP, GPCP and V4 ...

Jörg joerg.straube at iaeth.ch
Sun Jul 23 08:27:26 CEST 2017


Hi

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
PROCEDURE test*;
	VAR
		i: INTEGER;
		s: ARRAY 20 OF CHAR;
	BEGIN
		i := 1;
		s := „Hello World“;
	END test;

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
		statement1;
		statement2;
		statement3;
		statement4
	ELSE
		Error(15)
	END

I use this form if possible:
	IF i # 0 THEN Error(15)
	ELSE
		statement1;
		statement2;
		statement3;
		statement4
	END

br
Jörg


> Am 23.07.2017 um 03:13 schrieb Hans Klaver <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 
>> personal preference?
> 
> 
> 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.
> 
> --
> Hans Klaver
> 
> 
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20170723/24a2da79/attachment.html>


More information about the Oberon mailing list